Skip to content

Commit

Permalink
define service_longname when service specified
Browse files Browse the repository at this point in the history
  • Loading branch information
Audionut committed Sep 26, 2024
1 parent 69c0bce commit 3a4bebe
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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 ", "")
Expand Down

0 comments on commit 3a4bebe

Please sign in to comment.