1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-12-23 13:03:18 +00:00
musix-oss/node_modules/simple-youtube-api/dist/sya.min.js

1 line
22 KiB
JavaScript
Raw Normal View History

2019-05-30 09:06:47 +00:00
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.SimpleYoutubeAPI=e():t.SimpleYoutubeAPI=e()}(window,function(){return function(t){var e={};function s(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,s),i.l=!0,i.exports}return s.m=t,s.c=e,s.d=function(t,e,n){s.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},s.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},s.t=function(t,e){if(1&e&&(t=s(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(s.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)s.d(n,i,function(e){return t[e]}.bind(null,i));return n},s.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return s.d(e,"a",e),e},s.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},s.p="",s(s.s=4)}([function(t,e){e.PARTS={Search:"snippet",Videos:"snippet,contentDetails",Playlists:"snippet",PlaylistItems:"snippet,status",Channels:"snippet"},e.KINDS={Video:"youtube#video",PlaylistItem:"youtube#playlistItem",Playlist:"youtube#playlist",SearchResult:"youtube#searchResult",Channel:"youtube#channel"},e.ENDPOINTS={PlaylistItems:"playlistItems",Channels:"channels",Videos:"videos",Playlists:"playlists",Search:"search"}},function(t,e,s){const{parse:n}=s(8);e.parseURL=(t=>{const e=n(t,!0);switch(e.hostname){case"www.youtube.com":case"youtube.com":case"m.youtube.com":{const t=/^[a-zA-Z0-9-_]+$/;if("/watch"===e.pathname){if(!t.test(e.query.v))return{};const s={video:e.query.v};return e.query.list&&(s.playlist=e.query.list),s}if("/playlist"===e.pathname)return t.test(e.query.list)?{playlist:e.query.list}:{};if(e.pathname.startsWith("/channel/")){const s=e.pathname.replace("/channel/","");return t.test(s)?{channel:s}:{}}return{}}case"youtu.be":return{video:/^\/[a-zA-Z0-9-_]+$/.test(e.pathname)?e.pathname.slice(1):null};default:return{}}})},function(t,e,s){const{parseURL:n}=s(1),i=s(0);t.exports=class{constructor(t,e){this.youtube=t,Object.defineProperty(this,"youtube",{enumerable:!1}),this.type="channel",this._patch(e)}_patch(t){if(t){switch(this.raw=t,this.full=t.kind===i.KINDS.Channel,this.kind=t.kind,t.kind){case i.KINDS.Playlist:case i.KINDS.PlaylistItem:case i.KINDS.Video:if(t.snippet){this.id=t.snippet.channelId,this.title=t.snippet.channelTitle;break}throw new Error("Attempted to make a channel out of a resource with no channel data.");case i.KINDS.SearchResult:if(t.id.kind===i.KINDS.Channel){this.id=t.id.channelId;break}if(t.snippet){this.id=t.snippet.channelId,this.title=t.snippet.channelTitle;break}throw new Error("Attempted to make a channel out of a search result with no channel data.");case i.KINDS.Channel:this.id=t.id,t.snippet&&(this.title=t.snippet.title,this.description=t.snippet.description,this.customURL=t.snippet.customUrl,this.publishedAt=new Date(t.snippet.publishedAt),this.thumbnails=t.snippet.thumbnails,this.defaultLanguage=t.snippet.defaultLanguage,this.localized=t.snippet.localized,this.country=t.snippet.country),t.contentDetails&&(this.relatedPlaylists=t.contentDetails.relatedPlaylists),t.statistics&&(this.viewCount=t.statistics.viewCount,this.commentCount=t.statistics.commentCount,this.subscriberCount=t.statistics.subscriberCount,this.hiddenSubscriberCount=t.statistics.hiddenSubscriberCount,this.videoCount=t.statistics.videoCount);break;default:throw new Error(`Unknown channel kind: ${t.kind}.`)}return this}}fetch(t){return this.youtube.request.getChannel(this.id,t).then(this._patch.bind(this))}get url(){return`https://www.youtube.com/channel/${this.id}`}static extractID(t){return n(t).channel}}},function(t,e,s){const n=s(7),{parseURL:i}=s(1),r=s(0),o=s(2);t.exports=class{constructor(t,e){this.youtube=t,Object.defineProperty(this,"youtube",{enumerable:!1}),this.type="v