Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(helpers): infer audio/video from content type #651

Merged
merged 4 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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