Skip to content

Commit

Permalink
feat(helpers): infer audio/video from content type (#651)
Browse files Browse the repository at this point in the history
* feat(helpers): infer audio/video from content type

* chore(video): add content-type detection

* chore(audio): add content-type detection

* chore(media-provider): add content-type detection
  • Loading branch information
Kikobeats authored Aug 9, 2023
1 parent 42dac0d commit d6eed13
Show file tree
Hide file tree
Showing 35 changed files with 63,109 additions and 5,060 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
1,436 changes: 1,436 additions & 0 deletions packages/metascraper-audio/test/fixtures/providers/deezer.com.html

Large diffs are not rendered by default.

Loading

0 comments on commit d6eed13

Please sign in to comment.