From c4b4ab5bef30d1c6299effa226f45db3a8963bcd Mon Sep 17 00:00:00 2001 From: Mikael Larsson Date: Sun, 19 Feb 2017 11:50:33 +0100 Subject: [PATCH] tv4play: Add season and episode info in the filename --- lib/svtplay_dl/service/tv4play.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/svtplay_dl/service/tv4play.py b/lib/svtplay_dl/service/tv4play.py index 99a28d4..5da3acb 100644 --- a/lib/svtplay_dl/service/tv4play.py +++ b/lib/svtplay_dl/service/tv4play.py @@ -165,10 +165,24 @@ class Tv4play(Service, OpenGraphThumbMixin): show = quote_plus(show) return show + def _seasoninfo(self, data): + if "season" in data and data["season"]: + season = "{:02d}".format(data["season"]) + episode = "{:02d}".format(data["episode"]) + if int(season) == 0 and int(episode) == 0: + return None + return "s%se%s" % (season, episode) + else: + return None + def _autoname(self, vid): jsondata = self._get_show_info() for i in jsondata["results"]: if vid == i["id"]: + season = self._seasoninfo(i) + if season: + index = len(i["program"]["name"]) + return i["title"][:index] + ".%s%s" % (season, i["title"][index:]) return i["title"] return self._get_clip_info(vid)