@@ -2,8 +2,12 @@ const PLATFORM = "CDA";
2
2
3
3
var config = { } ;
4
4
5
- const VIDEO_SEARCH_URL = "www .cda.pl/video/show/ " ;
5
+ const VIDEO_SEARCH_URL = "api .cda.pl/video/search " ;
6
6
const VIDEO_URL = "www.cda.pl/video/" ;
7
+ const ANONYMOUS_REQUEST_PARAMS = {
8
+ Authorization : "Basic NzdjMGYzYzUtMzZhMC00YzNkLWIwZDQtMGM0ZGZiZmQ1NmQ1Ok5wbU1MQldSZ3RFWDh2cDNLZjNkMHRhc0JwRnQwdHVHc3dMOWhSMHF0N2JRZGF4dXZER29jekZHZXFkNjhOajI" ,
9
+ Accept : "application/vnd.cda.public+json" ,
10
+ } ;
7
11
8
12
//Source Methods
9
13
source . enable = function ( conf , settings , savedState ) {
@@ -109,42 +113,29 @@ source.getSubComments = function (comment) {
109
113
}
110
114
111
115
function 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 ) ;
114
118
115
- // log(res);
119
+ log ( res . code ) ;
116
120
if ( res . code != 200 ) {
117
121
return new VideoPager ( [ ] , false ) ;
118
122
}
123
+ log ( res . body . data ) ;
119
124
//const parser = new DOMParser();
120
125
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 => {
136
127
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 ) ] ) ,
140
131
author : new PlatformAuthorLink ( new PlatformID ( PLATFORM , "" , config . id ) , "" , "" , "" ) ,
141
132
uploadDate : 0 ,
142
- duration,
143
- viewCount : 0 ,
133
+ duration : video . duration ,
134
+ viewCount : video . views ,
144
135
url : "https://" + VIDEO_URL + videoID + "/vfilm" ,
145
136
isLive : false
146
137
} ) ;
147
- } ) , html . querySelectorAll ( ".sbmNext" ) . length > 0 , url , params , page ) ;
138
+ } ) , res . body . paginator . totalPages > page , url , params , page ) ;
148
139
}
149
140
150
141
class CDAVideoPager extends VideoPager {
0 commit comments