def xmlScience(self): """Generate EPG XML for Pluto Science""" channel_info, episodes = self.getChannel(term="science") channels = [] tvg_id = "SCIENCE" tvg_name = "Pluto Science" tvg_logo = self.channel_info["featuredImage"]["path"] channels.append({ "tvg_id": tvg_id, "tvg_name": tvg_name, "tvg_logo": tvg_logo }) programs = [] for episode in episodes: epg_desc = episode["episode"]["description"] epg_title = episode["title"] epg_start = convertEPGTime(episode["start"], epg_fmt=True) epg_stop = convertEPGTime(episode["stop"], epg_fmt=True) epg_icon = episode["episode"]["poster"]["path"] programs.append({ "tvg_id": tvg_id, "epg_title": epg_title, "epg_start": epg_start, "epg_stop": epg_stop, "epg_desc": epg_desc, "epg_icon": epg_icon }) url = furl(self.api_pluto_url).origin tpl = str(Path(__file__).parent.joinpath("templates/epg.tpl")) return template(tpl, channels=channels, programs=programs, url=url)
def xmlNFL(self): """Generate xml for NFL Streams""" channels = [] programs = [] for stream in self.getStreamsNFL(): tvg_id = stream.get("stream_id") tvg_name = stream.get("name").split(":")[0].strip() tvg_logo = stream.get("stream_icon") # tvg_group = "NFL Sunday Games" epg_desc = stream.get("name").split(":", maxsplit=1)[1].strip() ##### THIS IS TEMPORARY FOR SUPER BOWL FIX #### # epg_desc = epg_desc.replace("02.11", "02.13") # if epg_desc := stream.get("name").split(":", maxsplit=1)[1].strip(): if epg_desc: try: epg_title = epg_desc.split('(')[0].strip() date_now = getEPGTimeNow(dt_obj=True).date() year_now = str(date_now.year)[-2:] game_time = epg_desc.split('(')[1].strip().split( ')')[0].strip() regex = r'(\d+).(\d+)\s+(\d+):(\d+)\s*(\w*)\s*(\w*)' game_datetime = pd.to_datetime( re.sub(regex, rf'\1.\2.{year_now} \3:\4 \5', game_time)) epg_start = convertEPGTime( game_datetime.tz_localize('US/Eastern'), epg_fmt=True) epg_stop = convertEPGTime(pd.to_datetime(epg_start) + pd.DateOffset(hours=3), epg_fmt=True) if ((date_now - game_datetime.date()).days < 5): channels.append({ "tvg_id": tvg_id, "tvg_name": tvg_name, "tvg_logo": tvg_logo, "epg_desc": epg_desc }) programs.append({ "tvg_id": tvg_id, "epg_title": epg_title, "epg_start": epg_start, "epg_stop": epg_stop, "epg_desc": epg_desc }) except Exception as e: inspect(e) pass # return gen_xmltv_xml(channels=channels, programs=programs, url=self.API_URL) url = furl(self.API_URL).origin tpl = str(Path(__file__).parent.joinpath("templates/epg.tpl")) return template(tpl, channels=channels, programs=programs, url=url)
def xmlNFL(self): """Generate xml for NFL Streams""" channels = [] programs = [] for stream in self.getStreamsNFL(): tvg_id = stream.get("stream_id") tvg_name = stream.get("name").split(":")[0].strip() tvg_logo = "http://line.lemotv.cc/images/d7a1c666d3827922b7dfb5fbb9a3b450.png" # tvg_group = "NFL Sunday Games" epg_desc = stream.get("name").split(":", maxsplit=1)[1].strip() # if epg_desc := stream.get("name").split(":", maxsplit=1)[1].strip(): if epg_desc: try: epg_title = epg_desc.split('@')[0].strip() date_now = getEPGTimeNow(dt_obj=True).date() game_time = epg_desc.split('@')[1].strip() if date_now.weekday() == 6: game_datetime = pd.to_datetime( f'{date_now} {game_time}') else: game_datetime = pd.to_datetime( f'{(getEPGTimeNow(dt_obj=True) + Week(weekday=6)).date()} {game_time}' ) epg_start = convertEPGTime( game_datetime.tz_localize('US/Eastern'), epg_fmt=True) epg_stop = convertEPGTime(pd.to_datetime(epg_start) + pd.DateOffset(hours=3), epg_fmt=True) if ((date_now - game_datetime.date()).days < 5): channels.append({ "tvg_id": tvg_id, "tvg_name": tvg_name, "tvg_logo": tvg_logo, "epg_desc": epg_desc }) programs.append({ "tvg_id": tvg_id, "epg_title": epg_title, "epg_start": epg_start, "epg_stop": epg_stop, "epg_desc": epg_desc }) except Exception: pass # return gen_xmltv_xml(channels=channels, programs=programs, url=self.API_URL) url = furl(self.API_URL).origin tpl = str(Path(__file__).parent.joinpath("templates/epg.tpl")) return template(tpl, channels=channels, programs=programs, url=url)
def xmlESPN(self, terms=""): """Generate xml NBA Streams""" channels = [] programs = [] for stream in self.getStreamsESPN(terms=terms): tvg_id = stream.get("stream_id") tvg_name = stream.get("name").split(":")[0].strip() tvg_logo = "https://artwork.espncdn.com/programs/14ef54cc-6fd8-443d-80b8-365c1f64d606/16x9/large_20211213222642.jpg" # tvg_group = "ESPN+" epg_desc = stream.get("name").split(":", maxsplit=1)[1].strip() # if epg_desc := stream.get("name").split(":", maxsplit=1)[1].strip(): if epg_desc: try: epg_title = epg_desc.split(' ')[0].strip() date_now = getEPGTimeNow(dt_obj=True).date() game_time = epg_desc.split(' ')[1].split('et')[0].strip() game_datetime = pd.to_datetime(f'{date_now} {game_time}') epg_start = convertEPGTime( game_datetime.tz_localize('US/Eastern'), epg_fmt=True) epg_stop = convertEPGTime(pd.to_datetime(epg_start) + pd.DateOffset(hours=3), epg_fmt=True) if ((date_now - game_datetime.date()).days < 5): channels.append({ "tvg_id": tvg_id, "tvg_name": tvg_name, "tvg_logo": tvg_logo, "epg_desc": epg_desc }) programs.append({ "tvg_id": tvg_id, "epg_title": epg_title, "epg_start": epg_start, "epg_stop": epg_stop, "epg_desc": epg_desc }) except Exception: pass # return gen_xmltv_xml(channels=channels, programs=programs, url=self.API_URL) url = furl(self.API_URL).origin tpl = str(Path(__file__).parent.joinpath("templates/epg.tpl")) return template(tpl, channels=channels, programs=programs, url=url)