@@ -650,6 +650,10 @@ let configuration, init, Update;
650650 document . body . append ( frame ) ;
651651 }
652652
653+ function TLDHost ( host ) {
654+ return host . replace ( / ^ ( w w \w + | \w { 2 } ) \. / , '' ) ;
655+ }
656+
653657 // Send an update query to background.js
654658 Update = ( type , options = { } , postToo ) => {
655659 if ( configuration )
@@ -1044,7 +1048,7 @@ let configuration, init, Update;
10441048 } ;
10451049
10461050 if ( configuration ) {
1047- let host = location . host . replace ( / ^ ( w w \w + \. ) / , '' ) ,
1051+ let host = TLDHost ( location . host ) ,
10481052 doms = configuration . __domains . split ( ',' ) ;
10491053
10501054 if ( ! ~ doms . indexOf ( host ) )
@@ -1098,7 +1102,9 @@ let configuration, init, Update;
10981102 tid = TVDbID || null , // TVDbID
10991103 rqut = apit , // request type: tmdb, imdb, or tvdb
11001104 manable = __CONFIG__ . ManagerSearch && ! ( rerun & 0b1000 ) , // is the user's "Manager Searches" option enabled?
1101- UTF_16 = / [ ^ 0 \u0020 - \u007e , 1 \u00a1 \u00bf - \u00ff , 2 \u0100 - \u017f , 3 \u0180 - \u024f , 4 \u0300 - \u036f , 5 \u0370 - \u03ff , 6 \u0400 - \u04ff , 7 \u0500 - \u052f , 8 \u20a0 - \u20bf ] + / g;
1105+ UTF_16 = / [ ^ 0 \u0020 - \u007e , 1 \u00a1 \u00bf - \u00ff , 2 \u0100 - \u017f , 3 \u0180 - \u024f , 4 \u0300 - \u036f , 5 \u0370 - \u03ff , 6 \u0400 - \u04ff , 7 \u0500 - \u052f , 8 \u20a0 - \u20bf ] + / g,
1106+ MV = / ^ ( m o v i e s ? | f i l m s ? | c i n e m a s ? ) $ / i. test ( apit ) ,
1107+ TV = / ^ ( t v [ \s \- ] * (?: s h o w s ? | s e r i e s ) ? ) $ / i. test ( apit ) ;
11021108
11031109 type = type || null ;
11041110 meta = { ...meta , mode : 'cors' } ;
@@ -1150,9 +1156,9 @@ let configuration, init, Update;
11501156 /* the rest of this function is a beautiful mess that will need to be dealt with later... but it works */
11511157 let url =
11521158 ( manable && title && __CONFIG__ . usingOmbi && __CONFIG__ . ombiURLRoot ) ?
1153- `${ __CONFIG__ . ombiURLRoot } api/v1/Search/${ ( rqut == 'imdb' || rqut == 'tmdb' || apit == 'movie' ) ? 'movie' : 'tv' } /${ plus ( title , '%20' ) } /?apikey=${ api . ombi } ` :
1159+ `${ __CONFIG__ . ombiURLRoot } api/v1/Search/${ ( / ^ [ i t ] m d b $ / i . test ( rqut ) || MV ) ? 'movie' : 'tv' } /${ plus ( title , '%20' ) } /?apikey=${ api . ombi } ` :
11541160 ( manable && ( __CONFIG__ . usingRadarr || __CONFIG__ . usingSonarr || __CONFIG__ . usingMedusa /*|| __CONFIG__.usingSickBeard*/ ) ) ?
1155- ( __CONFIG__ . usingRadarr && ( rqut == 'imdb' || rqut == 'tmdb' ) && __CONFIG__ . radarrURLRoot ) ?
1161+ ( __CONFIG__ . usingRadarr && / ^ [ i t ] m d b $ / i . test ( rqut ) && __CONFIG__ . radarrURLRoot ) ?
11561162 ( mid ) ?
11571163 `${ __CONFIG__ . radarrURLRoot } api/movie/lookup/tmdb?tmdbId=${ mid } &apikey=${ __CONFIG__ . radarrToken } ` :
11581164 ( iid ) ?
@@ -1168,22 +1174,22 @@ let configuration, init, Update;
11681174 `${ __CONFIG__ . medusaURLRoot } api/v2/internal/searchIndexersForShowName?query=${ plus ( title ) } &indexerId=0&api_key=${ __CONFIG__ . medusaToken } ` :
11691175 /* TODO: find a way to get CORS to work on Sick Beard URLs (localhost) */
11701176 // (__CONFIG__.usingSickBeard)?
1171- // (tid)?
1172- // `${ __CONFIG__.sickBeardURLRoot }api/${ __CONFIG__.sickBeardToken }/?cmd=sb.searchtvdb&tvdbid=${ tid }`:
1173- // `${ __CONFIG__.sickBeardURLRoot }api/${ __CONFIG__.sickBeardToken }/?cmd=sb.searchtvdb&name=${ encodeURIComponent(title) }`:
1177+ // (tid)?
1178+ // `${ __CONFIG__.sickBeardURLRoot }api/${ __CONFIG__.sickBeardToken }/?cmd=sb.searchtvdb&tvdbid=${ tid }`:
1179+ // `${ __CONFIG__.sickBeardURLRoot }api/${ __CONFIG__.sickBeardToken }/?cmd=sb.searchtvdb&name=${ encodeURIComponent(title) }`:
11741180 null :
11751181 ( rqut == 'imdb' || ( rqut == '*' && ! iid && title ) || ( rqut == 'tvdb' && ! iid && title && ! ( rerun & 0b1000 ) ) && ( rerun |= 0b1000 ) ) ?
11761182 ( iid ) ?
11771183 `https://www.omdbapi.com/?i=${ iid } &apikey=${ api . omdb } ` :
11781184 ( year ) ?
11791185 `https://www.omdbapi.com/?t=${ plus ( title ) } &y=${ year } &apikey=${ api . omdb } ` :
11801186 `https://www.omdbapi.com/?t=${ plus ( title ) } &apikey=${ api . omdb } ` :
1181- ( rqut == 'tmdb' || ( rqut == '*' && ! mid && title && year ) || apit == 'movie' ) ?
1187+ ( rqut == 'tmdb' || ( rqut == '*' && ! mid && title && year ) || MV ) ?
11821188 ( apit && apid ) ?
1183- `https://api.themoviedb.org/3/${ apit } /${ apid } ?api_key=${ api . tmdb } ` :
1189+ `https://api.themoviedb.org/3/${ MV ? 'movie' : 'tv' } /${ apid } ?api_key=${ api . tmdb } ` :
11841190 ( iid || mid || tid ) ?
11851191 `https://api.themoviedb.org/3/find/${ iid || mid || tid } ?api_key=${ api . tmdb } &external_source=${ iid ? 'imdb' : mid ? 'tmdb' : 'tvdb' } _id` :
1186- `https://api.themoviedb.org/3/search/${ apit } ?api_key=${ api . tmdb } &query=${ encodeURI ( title ) } ${ year ? '&year=' + year : '' } ` :
1192+ `https://api.themoviedb.org/3/search/${ MV ? 'movie' : 'tv' } ?api_key=${ api . tmdb } &query=${ encodeURI ( title ) } ${ year ? '&year=' + year : '' } ` :
11871193 ( rqut == 'tvdb' || ( rqut == '*' && ! tid && title ) || ( apid == tid ) ) ?
11881194 ( tid ) ?
11891195 `https://api.tvmaze.com/shows/?thetvdb=${ tid } ` :
@@ -1192,7 +1198,7 @@ let configuration, init, Update;
11921198 `https://api.tvmaze.com/search/shows?q=${ encodeURI ( title ) } ` :
11931199 ( title ) ?
11941200 ( apit && year ) ?
1195- `https://www.theimdbapi.org/api/find/${ apit } ?title=${ encodeURI ( title ) } &year=${ year } ` :
1201+ `https://www.theimdbapi.org/api/find/${ MV ? 'movie' : 'show' } ?title=${ encodeURI ( title ) } &year=${ year } ` :
11961202 `https://www.theimdbapi.org/api/find/movie?title=${ encodeURI ( title ) } ${ year ? '&year=' + year : '' } ` :
11971203 null ;
11981204
0 commit comments