tytd/Tesses.YouTubeDownloader.Ex.../Tesses.YouTubeDownloader.Ot.../JavaScript/tytd-jquery.min.js

1 line
2.8 KiB
JavaScript
Raw Permalink Normal View History

2022-05-10 14:00:07 +00:00
class TYTD{constructor(e,i){this.server=e,this.defaultres=i}get defaultRes(){return this.defaultres}set defaultRes(e){this.defaultres=e}get serverUrl(){return this.server}downloadItem(e,i){var t=new URL(`api/AddItemRes/${i}/${e}`,this.server).href;$.get(t,function(e){})}downloadItem(e){this.downloadItem(e,this.defaultres)}progress(e){var i=new URL("api/v2/Progress",this.server).href;$.get(i,function(i){e(JSON.parse(i))})}queuelist(e){var i=new URL("api/v2/QueueList",this.server).href;$.get(i,function(i){e(JSON.parse(i))})}getvideos(e){this.getvideoinfofiles(function(i){i.forEach(i=>{this.getvideoinfofile(i,e)})})}getplaylists(e){this.getplaylistinfofiles(function(i){i.forEach(i=>{this.getplaylistinfofile(i,e)})})}getchannels(e){this.getchannelinfofiles(function(i){i.forEach(i=>{this.getchannelinfofile(i,e)})})}getchannelinfo(e,i){this.getchannelinfofile(`${e}.json`,i)}getvideoinfo(e,i){this.getvideoinfofile(`${e}.json`,i)}getvideoinfofile(e,i){var t=new URL(`api/Storage/File/Info/${e}`,this.server).href;$.get(t,function(e){i(JSON.parse(e))})}getchannelinfofile(e,i){var t=new URL(`api/Storage/File/Channel/${e}`,this.server).href;$.get(t,function(e){i(JSON.parse(e))})}getvideoinfofiles(e){var i=new URL("api/Storage/GetFiles/Info",this.server).href;$.get(i,function(i){e(JSON.parse(i))})}getplaylistinfo(e){this.getplaylistinfofile(`${id}.json`,e)}getplaylistinfofile(e){var i=new URL(`api/Storage/File/Playlist/${filename}`,this.server).href;$.get(i,function(i){e(JSON.parse(i))})}getplaylistinfofiles(e){var i=new URL("api/Storage/GetFiles/Playlist",this.server).href;$.get(i,function(i){e(JSON.parse(i))})}getchannelinfofiles(e){var i=new URL("api/Storage/GetFiles/Channel",this.server).href;$.get(i,function(i){e(JSON.parse(i))})}getsubscriptions(e){var i=new URL("api/v2/subscriptions",this.server).href;$.get(i,function(i){e(JSON.parse(i))})}subscribe(e,i,t){var s=new URL(`api/v2/subscribe?id=${encodeURIComponent(e)}&conf=${t}&getinfo=${i}`,this.server).href;$.get(s,function(e){})}subscribe(e,i){var t=new URL(`api/v2/subscribe?id=${encodeURIComponent(e)}&conf=${i}`,this.server).href;$.get(t,function(e){})}unsubscribe(e){var i=new URL(`api/v2/unsubscribe?id=${encodeURIComponent(e)}`,this.server).href;$.get(i,function(e){})}resubscribe(e,i){var t=new URL(`api/v2/resubscribe?id=${encodeURIComponent(e)}&conf=${i}`,this.server).href;$.get(t,function(e){})}getfiles(e,i){var t=new URL(`api/Storage/GetFiles/${e}`,this.server).href;$.get(t,function(e){i(JSON.parse(e))})}getdirectories(e,i){var t=new URL(`api/Storage/GetDirectories/${e}`,this.server).href;$.get(t,function(e){i(JSON.parse(e))})}fileexists(e,i,t){var s=new URL(`api/Storage/FileExists/${e}`,this.server).href;$.get(s,function(e){"true"===e?i():t()})}directoryexists(e,i,t){var s=new URL(`api/Storage/DirectoryExists/${e}`,this.server).href;$.get(s,function(e){"true"===e?i():t()})}}