mirror of
https://codeberg.org/tacerus/teddit.git
synced 2024-11-25 16:49:26 +01:00
Merge pull request 'Rewrite domains of embedded/youtube media' (#187) from 3np/teddit:rewrite-youtube into main
Reviewed-on: https://codeberg.org/teddit/teddit/pulls/187
This commit is contained in:
commit
cc8b893fbc
@ -24,7 +24,7 @@ module.exports = function() {
|
||||
width: post_media.oembed.thumbnail_width,
|
||||
thumbnail: await downloadAndSave(post_media.oembed.thumbnail_url, '', false, true),
|
||||
author_name: post_media.oembed.author_name,
|
||||
author_url: post_media.oembed.author_url,
|
||||
author_url: replaceDomains(post_media.oembed.author_url),
|
||||
title: post_media.oembed.title,
|
||||
duration: null,
|
||||
is_gif: null,
|
||||
@ -37,9 +37,8 @@ module.exports = function() {
|
||||
let r = /iframe.*?src=\"(.*?)\"/;
|
||||
let src = r.exec(str)[1]
|
||||
let youtube_id = src.split('/embed/')[1].split('?')[0]
|
||||
// TODO: Invidious youtube URLs.
|
||||
let youtube_url = `https://youtube.com/watch?v=${youtube_id}`
|
||||
obj.media.embed_src = youtube_url
|
||||
obj.media.embed_src = replaceDomains(youtube_url)
|
||||
} catch(error) {
|
||||
console.error(`Error while trying to get src link from embed youtube html.`, error)
|
||||
}
|
||||
@ -67,7 +66,7 @@ module.exports = function() {
|
||||
source: 'external',
|
||||
height: post_media.oembed.height,
|
||||
width: post_media.oembed.width,
|
||||
provider_url: post_media.oembed.provider_url,
|
||||
provider_url: replaceDomains(post_media.oembed.provider_url),
|
||||
provider_name: post_media.oembed.provider_name,
|
||||
title: post_media.oembed.title,
|
||||
duration: null,
|
||||
@ -79,12 +78,12 @@ module.exports = function() {
|
||||
let str = post_media.oembed.html
|
||||
let r = /iframe.*?src=\"(.*?)\"/;
|
||||
let src = r.exec(str)[1]
|
||||
obj.media.embed_src = cleanUrl(src)
|
||||
obj.media.embed_src = replaceDomains(cleanUrl(src))
|
||||
} catch(error) {
|
||||
//console.error(`Error while trying to get src link from embed html.`, error)
|
||||
}
|
||||
if(!obj.media.embed_src) {
|
||||
obj.media.embed_src = post_media.oembed.url
|
||||
obj.media.embed_src = replaceDomains(post_media.oembed.url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user