diff --git a/src/prep.py b/src/prep.py index 8ae30b4a7..5c9170b90 100644 --- a/src/prep.py +++ b/src/prep.py @@ -606,6 +606,9 @@ async def gather_prep(self, meta, mode): meta['source'], meta['type'] = self.get_source(meta['type'], video, meta['path'], meta['is_disc'], meta) if meta.get('service', None) in (None, ''): meta['service'], meta['service_longname'] = self.get_service(video, meta.get('tag', ''), meta['audio'], meta['filename']) + elif meta.get('service'): + services = self.get_service(get_services_only=True) + meta['service_longname'] = max((k for k, v in services.items() if v == meta['service']), key=len, default=meta['service']) meta['uhd'] = self.get_uhd(meta['type'], guessit(meta['path']), meta['resolution'], meta['path']) meta['hdr'] = self.get_hdr(mi, bdinfo) meta['distributor'] = self.get_distributor(meta['distributor']) @@ -3004,8 +3007,7 @@ async def get_season_episode(self, video, meta): return meta - def get_service(self, video, tag, audio, guess_title): - service = guessit(video).get('streaming_service', "") + def get_service(self, video=None, tag=None, audio=None, guess_title=None, get_services_only=False): services = { '9NOW': '9NOW', '9Now': '9NOW', 'AE': 'AE', 'A&E': 'AE', 'AJAZ': 'AJAZ', 'Al Jazeera English': 'AJAZ', 'ALL4': 'ALL4', 'Channel 4': 'ALL4', 'AMBC': 'AMBC', 'ABC': 'AMBC', 'AMC': 'AMC', 'AMZN': 'AMZN', @@ -3053,6 +3055,10 @@ def get_service(self, video, tag, audio, guess_title): 'YT': 'YT', 'ZDF': 'ZDF', 'iP': 'iP', 'BBC iPlayer': 'iP', 'iQIYI': 'iQIYI', 'iT': 'iT', 'iTunes': 'iT' } + if get_services_only: + return services + service = guessit(video).get('streaming_service', "") + video_name = re.sub(r"[.()]", " ", video.replace(tag, '').replace(guess_title, '')) if "DTS-HD MA" in audio: video_name = video_name.replace("DTS-HD.MA.", "").replace("DTS-HD MA ", "")