Skip to content

Commit

Permalink
[Website - VEELY] Add seasons, episodes and duration (#862)
Browse files Browse the repository at this point in the history
  • Loading branch information
darodi authored May 23, 2022
1 parent 3b2d40b commit f391a23
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion resources/lib/websites/veely.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
from __future__ import unicode_literals

import re
from xml.etree import ElementTree

import urlquick
# noinspection PyUnresolvedReferences
from codequick import Listitem, Resolver, Route, Script
# noinspection PyUnresolvedReferences
from codequick.utils import urljoin_partial
from codequick.utils import urljoin_partial, strip_tags

from resources.lib import resolver_proxy
from resources.lib.web_utils import get_random_ua, unquote_plus
Expand All @@ -29,6 +30,9 @@
SSMP_API = "https://mm-v2.simplestream.com/ssmp/api.php?id=%s&env=%s"
STREAM_API = "https://v2-streams-elb.simplestreamcdn.com/api/%s/stream/%s?key=%s&platform=firefox"

SEASON_EPISODE_PATTERN = re.compile(r'S(\d+)\s.*Ep(\d+)')
DURATION_PATTERN = re.compile(r'(\d+) min')


@Route.register
def website_root(plugin, item_id, **kwargs):
Expand Down Expand Up @@ -118,6 +122,24 @@ def list_carousel_items(div, plot=None):
if plot is not None:
item.info['plot'] = plot

season_episode_tag = anchor_tag.find(".//p[@class='details']//span[@class='pull-left']")
if season_episode_tag is not None and season_episode_tag.text is not None:
season_episode = SEASON_EPISODE_PATTERN.findall(season_episode_tag.text)
if len(season_episode) > 0:
item.info['mediatype'] = "episode"
episode_str = season_episode[0][1]
item.info['episode'] = int(episode_str)
season_str = season_episode[0][0]
item.info['season'] = int(season_str)
item.label = "S" + season_str + "E" + episode_str + " - " + item.label

duration_tag = anchor_tag.find(".//p[@class='details']//span[@class='duration pull-right']")
if duration_tag is not None:
duration_html = ElementTree.tostring(duration_tag, encoding='utf8', method='html')
duration = DURATION_PATTERN.findall(strip_tags(str(duration_html)))
if len(duration) > 0:
item.info['duration'] = int(duration[0]) * 60

if "/watch/" in url or "/live/" in url:
if "/live/" in url:
item.info['plot'] = item.label
Expand Down

0 comments on commit f391a23

Please sign in to comment.