コード例 #1
0
def list_clusters():
    url = __URL_MAIN_PAGE + '/mediathek/'
    response = requests.get(url, headers=__HEADERS)
    html = response.read()
    pattern = '<li class="program">.*?href="(.*?)".*?<img src="(.*?)".*?title="(.*?)".*?</li>'
    clusters = re.findall(pattern, html, re.DOTALL)
    parser = HTMLParser()
    for url, thumb, title in clusters:
        title = parser.unescape(title.decode('utf-8', 'ignore'))
        gui.add_folder(title, thumb, {'f': 'cluster', 'url': url})
    gui.end_listing()
コード例 #2
0
ファイル: api.py プロジェクト: lozioangie/repo
def list_videos(resource, reliveOnly):
    try:
        json_url = RAN_API_BASE + resource
        print ("###########"+json_url)
        response = requests.get(json_url, headers={'Accept-Encoding': 'gzip'})
        videos = response.json()['contents']
    except:
        return gui.end_listing()
    try:
        is_livestream = videos[0]['type'] == 'livestream'
    except (KeyError, IndexError):
        is_livestream = False
    if is_livestream:
        videos = sorted(videos, key=lambda k: k.get('streamdate_start'))
        timestamp_now = time.time()
    for video in videos:
        if is_livestream:
            stream_date_end = video['streamdate_end']
            if stream_date_end >= timestamp_now:
                stream_date_start = video['streamdate_start']
                if stream_date_start <= timestamp_now:
                    duration_in_seconds = stream_date_end - timestamp_now
                    playable = True
                    print("YYY: "+video["resource"])
                    title = '[B][COLOR red]%s[/COLOR][/B]' % video['teaser']['title']
                    year = datetime.datetime.now().year
                else:
                    date = datetime.datetime.fromtimestamp(stream_date_start)
                    year = date.year
                    date = date.strftime('%d.%m.%Y, %H:%M')
                    duration_in_seconds = stream_date_end - stream_date_start
                    playable = False
                    title = video['teaser']['title']
                    title = '[COLOR blue]%s[/COLOR] %s' % (date, video['teaser']['title'])
            else:
                continue
        else:
            duration_in_seconds = video['duration_in_seconds']
            date = datetime.datetime.fromtimestamp(video['published'])
            year = date.year
            date = date.strftime('%d.%m.%Y')
            playable = True
            title = '[COLOR blue]%s[/COLOR] %s' % (date, video['teaser']['title'])
        resource = video['resource']
        thumb = video['teaser']['image']  # .replace('ran_app_1280x720', 'ran_app_512x288')
        desc = video['teaser']['image_alt'] or video['teaser']['title']

        if 'False' in reliveOnly or 'Relive' in video['teaser']['title'] or 'Re-Live' in video['teaser']['title']:
            gui.add_video(title, thumb, {'f': 'play', 'resource': resource},
                      {'Title': video['teaser']['title'], 'Plot': desc, 'Genre': 'Sport', 'Year': year},
                      duration_in_seconds, thumb, is_playable=playable)
    gui.make_info_view_possible()
    gui.info_view()
    gui.end_listing()
コード例 #3
0
ファイル: api.py プロジェクト: kodinerds/repo
def list_clusters():
    url = __URL_MAIN_PAGE + '/mediathek/'
    response = requests.get(url, headers=__HEADERS)
    html = response.read()
    pattern = '<li class="program">.*?href="(.*?)".*?<img src="(.*?)".*?title="(.*?)".*?</li>'
    clusters = re.findall(pattern, html, re.DOTALL)
    parser = HTMLParser()
    for url, thumb, title in clusters:
        title = parser.unescape(title.decode('utf-8', 'ignore'))
        gui.add_folder(title, thumb, {'f': 'cluster', 'url': url})
    gui.end_listing()
コード例 #4
0
ファイル: api.py プロジェクト: kodinerds/repo
def list_videos(resource):
    try:
        json_url = RAN_API_BASE + resource
        response = requests.get(json_url, headers={'Accept-Encoding': 'gzip'})
        videos = response.json()['contents']
    except:
        return gui.end_listing()
    try:
        is_livestream = videos[0]['type'] == 'livestream'
    except (KeyError, IndexError):
        is_livestream = False
    if is_livestream:
        videos = sorted(videos, key=lambda k: k.get('streamdate_start'))
        timestamp_now = time.time()
    for video in videos:
        if is_livestream:
            stream_date_end = video['streamdate_end']
            if stream_date_end >= timestamp_now:
                stream_date_start = video['streamdate_start']
                if stream_date_start <= timestamp_now:
                    duration_in_seconds = stream_date_end - timestamp_now
                    playable = True
                    title = '[B][COLOR red]%s[/COLOR][/B]' % video['teaser']['title']
                    year = datetime.datetime.now().year
                else:
                    date = datetime.datetime.fromtimestamp(stream_date_start)
                    year = date.year
                    date = date.strftime('%d.%m.%Y, %H:%M')
                    duration_in_seconds = stream_date_end - stream_date_start
                    playable = False
                    title = video['teaser']['title']
                    title = '[COLOR blue]%s[/COLOR] %s' % (date, video['teaser']['title'])
            else:
                continue
        else:
            duration_in_seconds = video['duration_in_seconds']
            date = datetime.datetime.fromtimestamp(video['published'])
            year = date.year
            date = date.strftime('%d.%m.%Y')
            playable = True
            title = '[COLOR blue]%s[/COLOR] %s' % (date, video['teaser']['title'])
        resource = video['resource']
        thumb = video['teaser']['image']  # .replace('ran_app_1280x720', 'ran_app_512x288')
        desc = video['teaser']['image_alt'] or video['teaser']['title']
        gui.add_video(title, thumb, {'f': 'play', 'resource': resource},
                      {'Title': video['teaser']['title'], 'Plot': desc, 'Genre': 'Sport', 'Year': year},
                      duration_in_seconds, thumb, is_playable=playable)
    gui.make_info_view_possible()
    gui.info_view()
    gui.end_listing()
コード例 #5
0
ファイル: index.py プロジェクト: smplgd/repo
def index():
    import thumbnails
    live_caption = api.get_number_livestreams()
    if live_caption:
        live_caption = '[B]Live (%s)[/B]' % live_caption
    else:
        live_caption = 'Live (%s)' % live_caption
    gui.add_folder(live_caption, thumbnails.THUMB_MAIN, {'f': 'videos', 'resource': '/ran-app/v1/livestreams.json'})
    gui.add_folder('Neueste Videos', thumbnails.THUMB_MAIN, {'f': 'videos', 'resource': '/ran-app/v1/videos.json'})
    gui.add_folder('Fussball', thumbnails.THUMB_MAIN, {'f': 'videos', 'resource': '/ran-app/v1/videos/fussball.json'})
    gui.add_folder('Tennis', thumbnails.THUMB_MAIN, {'f': 'videos', 'resource': '/ran-app/v1/videos/tennis.json'})
    gui.add_folder('NFL', thumbnails.THUMB_MAIN, {'f': 'videos', 'resource': '/ran-app/v1/videos/us-sport.json'})
    gui.add_folder('Boxen', thumbnails.THUMB_MAIN, {'f': 'videos', 'resource': '/ran-app/v1/videos/boxen.json'})
    gui.add_folder('Golf', thumbnails.THUMB_MAIN, {'f': 'videos', 'resource': '/ran-app/v1/videos/golf.json'})
    gui.end_listing()
コード例 #6
0
def index():
    import thumbnails
    live_caption = api.get_number_livestreams()
    if live_caption:
        live_caption = '[B]Live (%s)[/B]' % live_caption
    else:
        live_caption = 'Live (%s)' % live_caption
    gui.add_folder(
        live_caption, thumbnails.THUMB_MAIN, {
            'f': 'videos',
            'resource': '/ran-mega/mobile/v1/livestreams.json',
            'reliveOnly': False
        }, 'aktuelle Live Streams')
    gui.add_folder(
        'Neueste Videos', thumbnails.THUMB_MAIN, {
            'f': 'videos',
            'resource': '/ran-mega/mobile/v1/videos.json',
            'reliveOnly': False
        }, 'Liste der neuesten Videos - über alle Kategorien')
    gui.add_folder(
        'Neueste Videos - [COLOR blue] Re-Live only [/COLOR]',
        thumbnails.THUMB_MAIN, {
            'f': 'videos',
            'resource': '/ran-mega/mobile/v1/videos.json',
            'reliveOnly': True
        }, 'Liste der neuesten Re-Lives - über alle Kategorien')
    gui.add_folder(
        'Fussball', thumbnails.THUMB_MAIN, {
            'f': 'videos',
            'resource': '/ran-mega/mobile/v1/videos/fussball.json',
            'reliveOnly': False
        }, 'Liste der neuesten Fussball-Videos')
    gui.add_folder(
        'US-Sports', thumbnails.THUMB_MAIN, {
            'f': 'videos',
            'resource': '/ran-mega/mobile/v1/videos/us-sport.json',
            'reliveOnly': False
        }, 'Liste der neuesten US-Sport-Videos (NBA, NFL, NHL)')
    gui.add_folder(
        'US-Sports: [COLOR blue] Re-Live only [/COLOR]', thumbnails.THUMB_MAIN,
        {
            'f': 'videos',
            'resource': '/ran-mega/mobile/v1/videos/us-sport.json',
            'reliveOnly': True
        },
        'Liste der neuesten Re-Live-Videos des US-Sports auf ran.de (NBA, NFL, NHL)'
    )
    gui.add_folder(
        'Tennis', thumbnails.THUMB_MAIN, {
            'f': 'videos',
            'resource': '/ran-mega/mobile/v1/videos/tennis.json',
            'reliveOnly': False
        }, 'Liste der neuesten Tennis-Videos')
    gui.add_folder(
        'Handball', thumbnails.THUMB_MAIN, {
            'f': 'videos',
            'resource': '/ran-mega/mobile/v1/videos/handball.json',
            'reliveOnly': False
        }, 'Liste der neuesten Handball-Videos')
    gui.add_folder(
        'Boxen', thumbnails.THUMB_MAIN, {
            'f': 'videos',
            'resource': '/ran-mega/mobile/v1/videos/boxen.json',
            'reliveOnly': False
        }, 'Liste der neuesten Box-Videos')
    gui.add_folder(
        'Darts', thumbnails.THUMB_MAIN, {
            'f': 'videos',
            'resource': '/ran-mega/mobile/v1/videos/darts.json',
            'reliveOnly': False
        }, 'Liste der neuesten Darts-Videos')
    gui.add_folder(
        'eSports', thumbnails.THUMB_MAIN, {
            'f': 'videos',
            'resource': '/ran-mega/mobile/v1/videos/esport.json',
            'reliveOnly': False
        }, 'Liste der neuesten eSports-Videos')
    gui.add_folder(
        'DTM', thumbnails.THUMB_MAIN, {
            'f': 'videos',
            'resource': '/ran-mega/mobile/v1/videos/dtm.json',
            'reliveOnly': False
        },
        'Liste der neuesten Videos der Deutschen Tourenwagen Meisterschaft (DTM)'
    )
    gui.end_listing()
コード例 #7
0
def list_cluster(url):
    response = requests.get(url, headers=__HEADERS)
    html = response.read()
    if not list_seasons(html):
        _list_videos(html)
    gui.end_listing()
コード例 #8
0
def list_videos(url):
    response = requests.get(url, headers=__HEADERS)
    html = response.read()
    _list_videos(html)
    gui.end_listing()
コード例 #9
0
ファイル: api.py プロジェクト: kodinerds/repo
def list_cluster(url):
    response = requests.get(url, headers=__HEADERS)
    html = response.read()
    if not list_seasons(html):
        _list_videos(html)
    gui.end_listing()
コード例 #10
0
ファイル: api.py プロジェクト: kodinerds/repo
def list_videos(url):
    response = requests.get(url, headers=__HEADERS)
    html = response.read()
    _list_videos(html)
    gui.end_listing()