@@ -2,8 +2,12 @@ const PLATFORM = "CDA";
22
33var config = { } ;
44
5- const VIDEO_SEARCH_URL = "www .cda.pl/video/show/ " ;
5+ const VIDEO_SEARCH_URL = "api .cda.pl/video/search " ;
66const VIDEO_URL = "www.cda.pl/video/" ;
7+ const ANONYMOUS_REQUEST_PARAMS = {
8+ Authorization : "Basic NzdjMGYzYzUtMzZhMC00YzNkLWIwZDQtMGM0ZGZiZmQ1NmQ1Ok5wbU1MQldSZ3RFWDh2cDNLZjNkMHRhc0JwRnQwdHVHc3dMOWhSMHF0N2JRZGF4dXZER29jekZHZXFkNjhOajI" ,
9+ Accept : "application/vnd.cda.public+json" ,
10+ } ;
711
812//Source Methods
913source . enable = function ( conf , settings , savedState ) {
@@ -109,42 +113,29 @@ source.getSubComments = function (comment) {
109113}
110114
111115function getVideoPager ( path , params , page ) {
112- const url = VIDEO_SEARCH_URL + params . search . replace ( / / g , "_" ) + `/p ${ page } ?s=best ` ;
113- const res = http . GET ( `https://${ url } ` , { } ) ;
116+ const url = VIDEO_SEARCH_URL + "?query=" + encodeURI ( params . search ) + `&page= ${ page } &limit=20 ` ;
117+ const res = http . GET ( `https://${ url } ` , ANONYMOUS_REQUEST_PARAMS ) ;
114118
115- // log(res);
119+ log ( res . code ) ;
116120 if ( res . code != 200 ) {
117121 return new VideoPager ( [ ] , false ) ;
118122 }
123+ log ( res . body . data ) ;
119124 //const parser = new DOMParser();
120125
121- const html = domParser . parseFromString ( res . body . substring ( res . body . indexOf ( "<body" ) , res . body . lastIndexOf ( "</body>" ) + 7 ) ) ; ;
122-
123- const durationsConvert = [ 3600 , 60 , 1 ] ;
124- return new CDAVideoPager ( html . querySelectorAll ( ".video-clip-wrapper" ) . map ( video => {
125- const videoHref = video . querySelector ( "a.link-title-visit" ) ;
126- const videoID = videoHref . getAttribute ( "href" ) . replace ( `https://${ VIDEO_URL } ` , "" ) . replace ( "/vfilm" , "" ) ;
127- const durationArray = video . querySelector ( "span.timeElem" ) . text . split ( ":" ) ;
128- let duration = 0 ;
129- log ( durationArray ) ;
130- for ( let i = 1 ; i <= durationArray . length ; i ++ ) {
131- duration += durationArray [ durationArray . length - i ] * durationsConvert [ 3 - i ] ;
132- }
133-
134- const imgSrc = video . querySelector ( "img" ) . getAttribute ( "src" ) ;
135-
126+ return new CDAVideoPager ( res . body . data . map ( video => {
136127 return new PlatformVideo ( {
137- id : new PlatformID ( PLATFORM , videoID , config . id ) ,
138- name : videoHref . text ,
139- thumbnails : new Thumbnails ( [ new Thumbnail ( "https:" + imgSrc , 0 ) ] ) ,
128+ id : new PlatformID ( PLATFORM , video . id , config . id ) ,
129+ name : video . title ,
130+ thumbnails : new Thumbnails ( [ new Thumbnail ( video . thumb ) ] ) ,
140131 author : new PlatformAuthorLink ( new PlatformID ( PLATFORM , "" , config . id ) , "" , "" , "" ) ,
141132 uploadDate : 0 ,
142- duration,
143- viewCount : 0 ,
133+ duration : video . duration ,
134+ viewCount : video . views ,
144135 url : "https://" + VIDEO_URL + videoID + "/vfilm" ,
145136 isLive : false
146137 } ) ;
147- } ) , html . querySelectorAll ( ".sbmNext" ) . length > 0 , url , params , page ) ;
138+ } ) , res . body . paginator . totalPages > page , url , params , page ) ;
148139}
149140
150141class CDAVideoPager extends VideoPager {
0 commit comments