diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ada3d0..e1499ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ +* [v0.0.21](https://github.com/newt-sc/a4kSubtitles/releases/tag/service.subtitles.a4ksubtitles%2Fservice.subtitles.a4ksubtitles-0.0.21): + * TVShow year scrape from imdb when necessary + * [v0.0.20](https://github.com/newt-sc/a4kSubtitles/releases/tag/service.subtitles.a4ksubtitles%2Fservice.subtitles.a4ksubtitles-0.0.20): * Improve Subscene tvshow matching - * Exctract first sub file from zips when none is matched + * Extract first sub file from zips when none is matched * Fix Podnadpisi not working properly for tvshows * Fix non-ascii video file title issues * Add tvshow tests diff --git a/a4kSubtitles/lib/video.py b/a4kSubtitles/lib/video.py index a231015..cc30be3 100644 --- a/a4kSubtitles/lib/video.py +++ b/a4kSubtitles/lib/video.py @@ -4,9 +4,11 @@ import json import struct import hashlib +import re +import threading -from .kodi import xbmc, xbmcvfs -from . import logger, utils +from .kodi import xbmc, xbmcvfs, get_bool_setting +from . import logger, utils, request __64k = 65536 __longlong_format_char = 'q' @@ -63,6 +65,13 @@ def __set_subdb_hash(meta, filepath): finally: f.close() +def __scrape_tvshow_year(meta): + imdb_response = request.execute({'method': 'GET', 'url': 'https://www.imdb.com/title/' + meta.imdb_id}) + if imdb_response.status_code == 200: + show_year_match = re.search(r' %s \((.*?)\)"' % meta.tvshow, imdb_response.text) + if show_year_match: + meta.tvshow_year = show_year_match.group(1) + def get_meta(): meta = {} meta['year'] = xbmc.getInfoLabel('VideoPlayer.Year') @@ -105,4 +114,8 @@ def get_meta(): meta.is_tvshow = meta.tvshow != '' meta.is_movie = not meta.is_tvshow + if meta.is_tvshow and meta.imdb_id != '' and get_bool_setting('podnadpisi', 'enabled'): + meta.tvshow_year_thread = threading.Thread(target=__scrape_tvshow_year, args=(meta,)) + meta.tvshow_year_thread.start() + return meta diff --git a/a4kSubtitles/search.py b/a4kSubtitles/search.py index e72ef9d..5615f79 100644 --- a/a4kSubtitles/search.py +++ b/a4kSubtitles/search.py @@ -154,7 +154,7 @@ def search(core, params): meta = core.video.get_meta() meta.languages = __parse_languages(core, core.utils.unquote(params['languages']).split(',')) meta.preferredlanguage = __parse_language(core, params['preferredlanguage']) - core.logger.debug(lambda: core.json.dumps(meta, indent=2)) + core.logger.debug(lambda: core.json.dumps(meta, default=lambda o: '', indent=2)) if meta.imdb_id == '': core.logger.error('missing imdb id!') diff --git a/a4kSubtitles/services/podnadpisi.py b/a4kSubtitles/services/podnadpisi.py index 1cb1da7..0a0b802 100644 --- a/a4kSubtitles/services/podnadpisi.py +++ b/a4kSubtitles/services/podnadpisi.py @@ -12,6 +12,10 @@ def build_search_requests(core, service_name, meta): params['seasons'] = meta.season params['episodes'] = meta.episode params['movie_type'] = ['tv-series', 'mini-series'] + + meta.tvshow_year_thread.join() + if meta.tvshow_year: + params['year'] = meta.tvshow_year else: params['movie_type'] = 'movie' params['year'] = meta.year diff --git a/addon.xml b/addon.xml index c7851d7..b611c26 100644 --- a/addon.xml +++ b/addon.xml @@ -1,7 +1,7 @@ @@ -24,9 +24,12 @@ Supports: OpenSubtitles, BSPlayer, Podnadpisi.NET, SubDB, Subscene icon.png +[v0.0.21]: + * TVShow year scrape from imdb when necessary + [v0.0.20]: * Improve Subscene tvshow matching - * Exctract first sub file from zips when none is matched + * Extract first sub file from zips when none is matched * Fix Podnadpisi not working properly for tvshows * Fix non-ascii video file title issues * Add tvshow tests diff --git a/packages/addons.xml b/packages/addons.xml index b3bdd58..3277f9e 100644 --- a/packages/addons.xml +++ b/packages/addons.xml @@ -4,7 +4,7 @@ @@ -27,9 +27,12 @@ Supports: OpenSubtitles, BSPlayer, Podnadpisi.NET, SubDB, Subscene icon.png +[v0.0.21]: + * TVShow year scrape from imdb when necessary + [v0.0.20]: * Improve Subscene tvshow matching - * Exctract first sub file from zips when none is matched + * Extract first sub file from zips when none is matched * Fix Podnadpisi not working properly for tvshows * Fix non-ascii video file title issues * Add tvshow tests diff --git a/packages/addons.xml.crc b/packages/addons.xml.crc index 4f8f22c..ffb4e8b 100644 --- a/packages/addons.xml.crc +++ b/packages/addons.xml.crc @@ -1 +1 @@ -ce64fa5330ba39c0eb089278d215c932d0f9d6ac \ No newline at end of file +cb2c5a3c7846568f15ffc86dd3a3cc20dab27c70 \ No newline at end of file