Skip to content

Commit

Permalink
kinopoiskapiunofficial.tech
Browse files Browse the repository at this point in the history
Плагин переделан на работу с неофициальным API kinopoiskapiunofficial.tech
  • Loading branch information
Jenstel committed Oct 1, 2021
1 parent 72bd7b5 commit e1c0ca6
Show file tree
Hide file tree
Showing 10 changed files with 145 additions and 82 deletions.
6 changes: 6 additions & 0 deletions Contents/DefaultPrefs.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@
"label": "Включить отображение коллекций",
"type": "bool",
"default": "true"
},
{
"id": "api_key",
"label": "Ключ https://kinopoiskapiunofficial.tech/",
"type":"text",
"default":""
},
{
"id": "captcha_key",
Expand Down
18 changes: 11 additions & 7 deletions Contents/Libraries/Shared/kinoplex/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ def __setattr__(self, attr, val):
# sources section
# kinopoisk api
config['kinopoisk']['api']['base'] = 'https://ext.kinopoisk.ru/ios/5.0.0/%s'
config['kinopoisk']['api']['search'] = config.kinopoisk.api.base % 'getKPLiveSearch?keyword=%s'
config['kinopoisk']['api']['film_details'] = config.kinopoisk.api.base % 'getKPFilmDetailView?filmID=%s&still_limit=50&sr=1'
config['kinopoisk']['api']['search'] = 'https://kinopoiskapiunofficial.tech/api/v2.1/films/search-by-keyword?keyword=%s&page=%s'
config['kinopoisk']['api']['film_details'] = 'https://kinopoiskapiunofficial.tech/api/v2.2/films/%s'
config['kinopoisk']['api']['distributions'] = 'https://kinopoiskapiunofficial.tech/api/v2.2/films/%s/distributions'
config['kinopoisk']['api']['list_films'] = config.kinopoisk.api.base % 'getKPFilmsList?filmID=%s&type=%s'
config['kinopoisk']['api']['staff'] = config.kinopoisk.api.base % 'getStaffList?filmID=%s&type=all'
config['kinopoisk']['api']['film_reviews'] = config.kinopoisk.api.base % 'getKPReviews?filmID=%s&type=0&sortType=0'
config['kinopoisk']['api']['staff'] = 'https://kinopoiskapiunofficial.tech/api/v1/staff?filmId=%s'
config['kinopoisk']['api']['similars'] = 'https://kinopoiskapiunofficial.tech/api/v2.2/films/%s/similars'
config['kinopoisk']['api']['film_reviews'] = 'https://kinopoiskapiunofficial.tech/api/v1/reviews?filmId=%s&page=1'
config['kinopoisk']['api']['gallery'] = config.kinopoisk.api.base % 'getGallery?filmID=%s'
config['kinopoisk']['api']['series'] = config.kinopoisk.api.base % 'getKPSeriesList?serialID=%s&season=%s&page=%s'
config['kinopoisk']['api']['hash'] = 'IDATevHDS7'
Expand All @@ -39,17 +41,19 @@ def __setattr__(self, attr, val):
'Accept': 'application/json',
'device': 'android',
'Android-Api-Version': '22',
'X-API-KEY': '93fbd7a8-47d8-4c0d-a822-8615816c9536',
'User-Agent': 'Android client (4.4 / api22),ru.kinopoisk/4.2.1 (52)'
}

config['kinopoisk']['main']['search'] = 'https://www.kinopoisk.ru/search/suggest/?q=%s&topsuggest=true&ajax=1'
config['kinopoisk']['main']['search'] = 'https://kinopoiskapiunofficial.tech/api/v2.1/films/search-by-keyword?keyword=%s&page=%s'
config['kinopoisk']['main']['headers'] = lambda: {
'Referer': 'https://www.kinopoisk.ru',
'Accept': 'text/html, application/xhtml+xml, image/jxr, */*',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'en-US,en;q=0.8,ru;q=0.7,uk;q=0.5,de-DE;q=0.3,de;q=0.2',
'User-agent': generate_user_agent(),
'X-Compress': 'null',
'X-API-KEY': '93fbd7a8-47d8-4c0d-a822-8615816c9536',
'Upgrade-Insecure-Requests': '1'
}

Expand All @@ -58,8 +62,8 @@ def __setattr__(self, attr, val):
config['kinopoisk']['images'] = '%s'
config['kinopoisk']['imagesactor'] = 'https://st.kp.yandex.net/images/%s'
config['kinopoisk']['actor'] = config.kinopoisk.imagesactor % 'actor_iphone/iphone360_%s.jpg'
config['kinopoisk']['thumb'] = config.kinopoisk.images % 'film_iphone/iphone360_%s.jpg'
config['kinopoisk']['poster'] = config.kinopoisk.images % 'film_big/%s.jpg'
config['kinopoisk']['thumb'] = 'https://kinopoiskapiunofficial.tech/images/posters/kp_small/%s.jpg'
config['kinopoisk']['poster'] = 'https://kinopoiskapiunofficial.tech/images/posters/kp/%s.jpg'

config['kptrailers']['extras']['base'] = 'https://www.kinopoisk.ru/film/%s/video/'
config['kptrailers']['extras']['re'] = "//table[ancestor::table[2]]//div/a[@class='all' and contains(@href,'/film/')]"
Expand Down
18 changes: 10 additions & 8 deletions Contents/Libraries/Shared/kinoplex/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ def parse_meta(metadata_dict, metadata, api):
continue

dict_value = metadata_dict[attr_name]
if dict_value is None:
continue
try:
if isinstance(dict_value, list):

Expand Down Expand Up @@ -333,11 +335,11 @@ def prepare_meta(metadata_dict, metadata, app):
meta_staff.photo = staff.get('photo', '')
meta_staff.role = staff.get('role', '')

metadata.reviews.clear()
for review in metadata_dict.get('reviews', []):
r = metadata.reviews.new()
r.author = review.get('author')
r.source = review.get('source')
r.image = review.get('image')
r.link = review.get('link')
r.text = review.get('text')
if not (metadata_dict.get('reviews') is None):
for review in metadata_dict.get('reviews', []):
r = metadata.reviews.new()
r.author = review.get('author')
r.source = review.get('source')
r.image = review.get('image')
r.link = review.get('link')
r.text = review.get('text')
Binary file not shown.
2 changes: 1 addition & 1 deletion Contents/Libraries/Shared/kinoplex/sources/fanart.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def update(self, metadata, media, lang, force=False, periodic=False):
try:
json = self.api.JSON.ObjectFromURL(self.conf.movie % metadata['meta_ids'].get('tmdb'), headers=self.conf.headers(''))
except:
self.l.Debug('No data from FanArt.tv')
self.l.Debug('No data from FanArt.tv')

if json:
for key, value in json.items():
Expand Down
4 changes: 3 additions & 1 deletion Contents/Libraries/Shared/kinoplex/sources/itunes.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def _search(self, metadata, media):
self.d('search for itunes on rottentomatoes')
omdb = self.api.JSON.ObjectFromURL(self.conf.omdb % imdb_id)
if 'tomatoURL' in omdb and omdb['tomatoURL'] != 'N/A':
page = self.api.HTML.ElementFromURL(omdb['tomatoURL'].replace('http://', 'https://'), headers=self.c.headers.all, cacheTime=0)
tomatoURL = omdb['tomatoURL'].replace('http://', 'https://')
tomatoURL = tomatoURL.replace('https://rottentomatoes.com', 'https://www.rottentomatoes.com')
page = self.api.HTML.ElementFromURL(tomatoURL, headers=self.c.headers.all, cacheTime=0)
lnk = page.xpath(self.c.itunes.rt_re)
if len(lnk) > 0:
return re.search('(?<=id)[0-9]+', lnk[0]).group(0)
Expand Down
Loading

0 comments on commit e1c0ca6

Please sign in to comment.