Skip to content

Commit

Permalink
Merge 6b9c769 into fb366ce
Browse files Browse the repository at this point in the history
  • Loading branch information
newt-sc committed Jul 2, 2021
2 parents fb366ce + 6b9c769 commit 52d9a38
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* [v2.8.0](https://github.com/newt-sc/a4kSubtitles/releases/tag/service.subtitles.a4ksubtitles%2Fservice.subtitles.a4ksubtitles-2.8.0):
* Support tvshows with more than 250 episodes for episode id lookup when tvshow imdb id is provided.

* [v2.7.0](https://github.com/newt-sc/a4kSubtitles/releases/tag/service.subtitles.a4ksubtitles%2Fservice.subtitles.a4ksubtitles-2.7.0):
* Support tvshow imdb id, along with season and episode passed from video file url.

Expand Down
17 changes: 13 additions & 4 deletions a4kSubtitles/lib/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,13 @@ def filter_tvshow_results(result):
meta.imdb_id = result['id']
return

def __update_info_from_imdb(core, meta):
def __update_info_from_imdb(core, meta, pagination_token=''):
request = {
'method': 'POST',
'url': 'https://graphql.imdb.com',
'data': core.json.dumps({
'query': '''
query TitlesList($idArray: [ID!]!) {
query TitlesList($idArray: [ID!]!, $paginationToken: ID) {
titles(ids: $idArray) {
id
titleText {
Expand Down Expand Up @@ -215,12 +215,16 @@ def __update_info_from_imdb(core, meta):
}
fragment TMD_Episodes_EpisodesCardContainer on Episodes {
result: episodes(first: 99999) {
result: episodes(first: 250, after: $paginationToken) {
edges {
node {
...TMD_Episodes_EpisodeCard
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
Expand All @@ -242,7 +246,8 @@ def __update_info_from_imdb(core, meta):
''',
'operationName': 'TitlesList',
'variables': {
'idArray': [meta.imdb_id]
'idArray': [meta.imdb_id],
'paginationToken': pagination_token
},
}),
'headers': {
Expand Down Expand Up @@ -274,13 +279,17 @@ def __update_info_from_imdb(core, meta):
episodes = result['episodes']['result']['edges']
s_number = int(meta.season)
ep_number = int(meta.episode)
found = False
for episode in episodes:
ep = episode['node']
series = ep['series']['episodeNumber']
if series['episodeNumber'] == ep_number and series['seasonNumber'] == s_number:
meta.title = ep['titleText']['text']
meta.year = str(ep['releaseDate']['year'])
meta.imdb_id = ep['id']
found = True
if not found and result['episodes']['result']['pageInfo']['hasNextPage']:
return __update_info_from_imdb(core, meta, result['episodes']['result']['pageInfo']['endCursor'])
except:
return

Expand Down
7 changes: 5 additions & 2 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="service.subtitles.a4ksubtitles"
name="a4kSubtitles"
version="2.7.0"
version="2.8.0"
provider-name="Unknown">
<requires>
<import addon="script.module.requests"/>
Expand All @@ -12,7 +12,7 @@
<extension point="xbmc.addon.metadata">
<summary lang="en">a4kSubtitles - Multi-Source Subtitles Addon</summary>
<description>
Multi-source subtitles addon optimized for Seren.
Multi-source subtitles addon optimized for Seren and a4kScrapers.
Supports: OpenSubtitles, BSPlayer, Podnadpisi.NET, Subscene, Addic7ed
</description>
<platform>all</platform>
Expand All @@ -27,6 +27,9 @@ Supports: OpenSubtitles, BSPlayer, Podnadpisi.NET, Subscene, Addic7ed
<screenshot>screenshot-03.png</screenshot>
</assets>
<news>
[v2.8.0]:
* Support tvshows with more than 250 episodes for episode id lookup when tvshow imdb id is provided.

[v2.7.0]:
* Support tvshow imdb id, along with season and episode passed from video file url.

Expand Down
7 changes: 5 additions & 2 deletions packages/addons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<addons>
<addon id="service.subtitles.a4ksubtitles"
name="a4kSubtitles"
version="2.7.0"
version="2.8.0"
provider-name="Unknown">
<requires>
<import addon="script.module.requests"/>
Expand All @@ -15,7 +15,7 @@
<extension point="xbmc.addon.metadata">
<summary lang="en">a4kSubtitles - Multi-Source Subtitles Addon</summary>
<description>
Multi-source subtitles addon optimized for Seren.
Multi-source subtitles addon optimized for Seren and a4kScrapers.
Supports: OpenSubtitles, BSPlayer, Podnadpisi.NET, Subscene, Addic7ed
</description>
<platform>all</platform>
Expand All @@ -30,6 +30,9 @@ Supports: OpenSubtitles, BSPlayer, Podnadpisi.NET, Subscene, Addic7ed
<screenshot>screenshot-03.png</screenshot>
</assets>
<news>
[v2.8.0]:
* Support tvshows with more than 250 episodes for episode id lookup when tvshow imdb id is provided.

[v2.7.0]:
* Support tvshow imdb id, along with season and episode passed from video file url.

Expand Down
2 changes: 1 addition & 1 deletion packages/addons.xml.crc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a07bc81fc66ec05637abfa1e2c2a7a045ce9d912
33a5b4c976328bc2d1eb4d2b36349fa076540386
22 changes: 20 additions & 2 deletions tests/test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def test_opensubtitles_tvshow_missing_imdb_id_but_in_url():
'episode': '',
'url': 'https://example.com/example.mkv?imdb_id=tt11610548'
}
search = __search_movie(a4ksubtitles_api, settings, video_meta)
search = __search_tvshow(a4ksubtitles_api, settings, video_meta)

assert len(search.results) > 0

Expand All @@ -410,7 +410,7 @@ def test_opensubtitles_tvshow_missing_imdb_id_but_in_url_with_show_id_and_meta_f
'episode': '',
'url': 'https://example.com/example.mkv?imdb_id=tt10155688&season=1&episode=2'
}
search = __search_movie(a4ksubtitles_api, settings, video_meta)
search = __search_tvshow(a4ksubtitles_api, settings, video_meta)

assert len(search.results) > 0

Expand Down Expand Up @@ -524,6 +524,24 @@ def test_podnadpisi_tvshow():

assert filepath != ''

def test_podnadpisi_tvshow_missing_imdb_id_but_in_url_with_show_id_and_meta_for_ep_and_season_with_paging():
a4ksubtitles_api = api.A4kSubtitlesApi({'kodi': True})
__remove_all_cache(a4ksubtitles_api)

# search
settings = {
'podnadpisi.enabled': 'true',
}
video_meta = {
'imdb_id': '',
'season': '',
'episode': '',
'url': 'https://example.com/example.mkv?imdb_id=tt0239195&season=20&episode=2'
}
search = __search_tvshow(a4ksubtitles_api, settings, video_meta)

assert len(search.results) > 0

def test_subscene():
a4ksubtitles_api = api.A4kSubtitlesApi({'kodi': True})
__remove_all_cache(a4ksubtitles_api)
Expand Down

0 comments on commit 52d9a38

Please sign in to comment.