Skip to content

Commit

Permalink
chore(audio): add content-type detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Aug 8, 2023
1 parent 4e76a61 commit 6e408f9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions packages/metascraper-audio/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,19 @@ const withContentType = (url, contentType) =>
isMime(contentType, 'audio') ? url : false

const audioRules = [
toAudio($ => $('meta[property="og:audio:secure_url"]').attr('content')),
toAudio($ => $('meta[property="og:audio"]').attr('content')),
({ url, htmlDom: $ }) => {
const src =
$('meta[property="og:audio:secure_url"]').attr('content') ||
$('meta[property="og:audio:url"]').attr('content') ||
$('meta[property="og:audio"]').attr('content')

return src
? audio(src, {
url,
type: $('meta[property="og:audio:type"]').attr('content')
})
: undefined
},
toAudio($ => {
const contentType =
$('meta[name="twitter:player:stream:content_type"]').attr('content') ||
Expand Down
2 changes: 1 addition & 1 deletion packages/metascraper-video/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const toVideoFromDom = toRule((domNodes, opts) => {
})

const videoRules = [
async ({ url, htmlDom: $ }) => {
({ url, htmlDom: $ }) => {
const src =
$('meta[property="og:video:secure_url"]').attr('content') ||
$('meta[property="og:video:url"]').attr('content') ||
Expand Down

0 comments on commit 6e408f9

Please sign in to comment.