mirror of
https://github.com/wukko/cobalt.git
synced 2025-02-23 19:48:48 +01:00
api/facebook: add dispatcher support (#1115)
This commit is contained in:
parent
a52aee2bb3
commit
dba405a6b4
2 changed files with 7 additions and 6 deletions
|
@ -227,7 +227,8 @@ export default async function({ host, patternMatch, params }) {
|
|||
|
||||
case "facebook":
|
||||
r = await facebook({
|
||||
...patternMatch
|
||||
...patternMatch,
|
||||
dispatcher
|
||||
});
|
||||
break;
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@ const headers = {
|
|||
'Sec-Fetch-Site': 'none',
|
||||
}
|
||||
|
||||
const resolveUrl = (url) => {
|
||||
return fetch(url, { headers })
|
||||
const resolveUrl = (url, dispatcher) => {
|
||||
return fetch(url, { headers, dispatcher })
|
||||
.then(r => {
|
||||
if (r.headers.get('location')) {
|
||||
return decodeURIComponent(r.headers.get('location'));
|
||||
|
@ -23,13 +23,13 @@ const resolveUrl = (url) => {
|
|||
.catch(() => false);
|
||||
}
|
||||
|
||||
export default async function({ id, shareType, shortLink }) {
|
||||
export default async function({ id, shareType, shortLink, dispatcher }) {
|
||||
let url = `https://web.facebook.com/i/videos/${id}`;
|
||||
|
||||
if (shareType) url = `https://web.facebook.com/share/${shareType}/${id}`;
|
||||
if (shortLink) url = await resolveUrl(`https://fb.watch/${shortLink}`);
|
||||
if (shortLink) url = await resolveUrl(`https://fb.watch/${shortLink}`, dispatcher);
|
||||
|
||||
const html = await fetch(url, { headers })
|
||||
const html = await fetch(url, { headers, dispatcher })
|
||||
.then(r => r.text())
|
||||
.catch(() => false);
|
||||
|
||||
|
|
Loading…
Reference in a new issue