Skip to content

Commit

Permalink
Support youtube-nocookie.com
Browse files Browse the repository at this point in the history
  • Loading branch information
webmiraclepro committed May 22, 2020
1 parent 99bac29 commit 3623ceb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/patterns.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const MATCH_URL_YOUTUBE = /(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})|youtube\.com\/playlist\?list=|youtube\.com\/user\/?/
export const MATCH_URL_YOUTUBE = /(?:youtu\.be\/|youtube(?:-nocookie)?\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})|youtube\.com\/playlist\?list=|youtube\.com\/user\//
export const MATCH_URL_SOUNDCLOUD = /(?:soundcloud\.com|snd\.sc)\/[^.]+$/
export const MATCH_URL_VIMEO = /vimeo\.com\/.+/
export const MATCH_URL_FACEBOOK = /^https?:\/\/(www\.)?facebook\.com.*\/(video(s)?|watch|story)(\.php?|\/).+$/
Expand Down
3 changes: 3 additions & 0 deletions src/players/YouTube.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const SDK_GLOBAL = 'YT'
const SDK_GLOBAL_READY = 'onYouTubeIframeAPIReady'
const MATCH_PLAYLIST = /list=([a-zA-Z0-9_-]+)/
const MATCH_USER_UPLOADS = /user\/([a-zA-Z0-9_-]+)\/?/
const MATCH_NOCOOKIE = /youtube-nocookie\.com/
const NOCOOKIE_HOST = 'https://www.youtube-nocookie.com'

function parsePlaylist (url) {
if (MATCH_PLAYLIST.test(url)) {
Expand Down Expand Up @@ -77,6 +79,7 @@ export default class YouTube extends Component {
onStateChange: this.onStateChange,
onError: event => onError(event.data)
},
host: MATCH_NOCOOKIE.test(url) ? NOCOOKIE_HOST : undefined,
...embedOptions
})
}, onError)
Expand Down

0 comments on commit 3623ceb

Please sign in to comment.