Пример #1
0
def get_episodes(params):
    page = params.get('page', 0)
    url = config.EPISODEQUERY_URL.format(urllib.unquote(params['query']), page,
                                         params['season'])
    if params['category'] == 'News' or params['category'] == 'Sport':
        url = url.replace('&all=video_type_long_form:Full+Episodes', '')
    data = json.loads(fetch_url(url))
    listing = []
    for episode in data['items']:
        e = classes.episode()
        e.thumb = episode['videoStillURL']
        e.fanart = urllib.unquote(params.get('fanart', ''))
        e.title = episode['customFields'].get('clip_title')
        if not e.title:
            e.title = episode.get('name')
        e.desc = episode['shortDescription']
        e.duration = episode['length'] / 1000
        e.airdate = episode['customFields']['start_date_act']
        e.page = int(page)
        e.id = episode['id']
        e.hlsurl = episode['HLSURL']
        e.total_episodes = int(data['total_count'])
        if e.total_episodes > 30:
            e.query = urllib.quote(params['query'])
            e.season = params['season']
            e.category = params['category']
        listing.append(e)
    return listing
Пример #2
0
def get_featured():
    data = json.loads(fetch_url(config.FEATURED_URL))
    listing = []
    for episode in data:
        e = classes.episode()
        e.title = episode['name']
        if not e.title:
            continue
        e.thumb = episode['videoStillURL']
        e.desc = episode['short_description']
        e.id = episode['brightcoveid']
        listing.append(e)
    return listing
Пример #3
0
 def get_clipmetadata(episode):
     e = classes.episode()
     e.episode_no = 'CLIP'
     #str(episode['episodeNumber'])
     e.thumb = episode['image']['sizes'].get('w480')
     e.fanart = data['tvSeries']['image']['sizes'].get('w1280')
     e.episode_name = episode.get('name').encode('utf8')
     #e.title = 'CLIP:'+ e.get_title()
     e.title = e.get_title()
     e.desc = utils.ensure_ascii(episode.get('description'))
     e.duration = episode['video'].get('duration')//1000
     e.airdate = episode.get('airDate')
     e.id = episode['video'].get('referenceId')
     e.drm = episode['video'].get('drm')
     return e
    def get_metadata(episode):
        if not episode:
            return
        # filter extras again as some show are unable to be filtered at the
        # previous step
        if not episode.get('episodeNumber'):
            return
        # make sure season numbers match, some shows return all seasons.
        if episode['partOfSeason'].get('slug') != params['season_slug']:
            return

        e = classes.episode()
        e.episode_no = str(episode['episodeNumber'])
        e.thumb = episode['image']['sizes'].get('w480')
        e.fanart = data['tvSeries']['image']['sizes'].get('w1280')
        e.episode_name = episode.get('name').encode('utf8')
        e.title = e.get_title()
        e.desc = utils.ensure_ascii(episode.get('description'))
        e.duration = episode['video'].get('duration')//1000
        e.airdate = episode.get('airDate')
        e.id = episode['video'].get('referenceId')
        e.drm = episode['video'].get('drm')
        return e
Пример #5
0
    def get_metadata(episode):
        if not episode:
            return
        # filter extras again as some show are unable to be filtered at the
        # previous step
        if not episode.get('episodeNumber'):
            return
        # make sure season numbers match, some shows return all seasons.
        if episode['partOfSeason'].get('slug') != params['season_slug']:
            return

        e = classes.episode()
        e.episode_no = str(episode['episodeNumber'])
        e.thumb = episode['image']['sizes'].get('w480')
        e.fanart = data['tvSeries']['image']['sizes'].get('w1280')
        e.episode_name = episode.get('name').encode('utf8')
        e.title = e.get_title()
        e.desc = utils.ensure_ascii(episode.get('description'))
        e.duration = episode['video'].get('duration')//1000
        e.airdate = episode.get('airDate')
        e.id = episode['video'].get('referenceId')
        e.drm = episode['video'].get('drm')
        return e
Пример #6
0
def list_episodes(params):
    """
    Create and return list of episode objects
    """
    url = config.EPISODEQUERY_URL.format(
        params['series_slug'], params['season_slug'])
    res = fetch_url(url)
    data = json.loads(res)
    listing = []
    for section in data['items']:
        # filter extras etc for most shows.
        if section.get('callToAction'):
            if (section['callToAction']['link']['type'] not in
               ['episode-index', 'external']):
                continue
        for episode in section['items']:
            # filter extras again as some show are unable to be filtered at the
            # previous step
            if not episode.get('episodeNumber'):
                continue
            # make sure season numbers match, some shows return all seasons.
            if episode['partOfSeason'].get('slug') != params['season_slug']:
                continue

            e = classes.episode()
            e.episode_no = str(episode['episodeNumber'])
            e.thumb = episode['image']['sizes'].get('w480')
            e.fanart = data['tvSeries']['image']['sizes'].get('w1280')
            e.episode_name = episode.get('name').encode('utf8')
            e.title = e.get_title()
            e.desc = episode.get('description')
            e.duration = episode['video'].get('duration')//1000
            e.airdate = episode.get('airDate')
            e.id = episode['video'].get('referenceId')
            e.drm = episode['video'].get('drm')
            listing.append(e)
    return listing
Пример #7
0
def list_episodes(params):
    """
    Create and return list of episode objects
    """
    def get_metadata(episode):
        if not episode:
            return
        # filter extras again as some show are unable to be filtered at the
        # previous step
        if not episode.get('episodeNumber'):
            return
        # make sure season numbers match, some shows return all seasons.
        if episode['partOfSeason'].get('slug') != params['season_slug']:
            return

        e = classes.episode()
        e.episode_no = str(episode['episodeNumber'])
        e.thumb = episode['image']['sizes'].get('w480')
        e.fanart = data['tvSeries']['image']['sizes'].get('w1280')
        e.episode_name = episode.get('name').encode('utf8')
        e.title = e.get_title()
        e.desc = utils.ensure_ascii(episode.get('description'))
        e.duration = episode['video'].get('duration')//1000
        e.airdate = episode.get('airDate')
        e.id = episode['video'].get('referenceId')
        e.drm = episode['video'].get('drm')
        return e
    
    def get_clipmetadata(episode):
        e = classes.episode()
        e.episode_no = 'CLIP'
        #str(episode['episodeNumber'])
        e.thumb = episode['image']['sizes'].get('w480')
        e.fanart = data['tvSeries']['image']['sizes'].get('w1280')
        e.episode_name = episode.get('name').encode('utf8')
        #e.title = 'CLIP:'+ e.get_title()
        e.title = e.get_title()
        e.desc = utils.ensure_ascii(episode.get('description'))
        e.duration = episode['video'].get('duration')//1000
        e.airdate = episode.get('airDate')
        e.id = episode['video'].get('referenceId')
        e.drm = episode['video'].get('drm')
        return e

    listing = []

    url = config.EPISODEQUERY_URL.format(
        params['series_slug'], params['season_slug']+'/episodes')
    data = fetch_url(url)
    for episode in data['episodes'].get('items'):
        e = get_metadata(episode)
        if e:
            listing.append(e)
    url = config.EPISODEQUERY_URL.format(
        params['series_slug'], params['season_slug'])
    data = fetch_url(url)
    if data['items'][0].get('title') == 'Latest Clips': 
    #    add menu item for "All Clips"
        e = classes.episode()
        e.episode_no = 'ALLCLIPS'
        e.duration = 0
        e.title = 'All Clips'
        e.series_slug = params['series_slug']
        e.season_slug = params['season_slug']
        
        listing.append(e)
        
        for episode in data['items'][0].get('items'):
            e = get_clipmetadata(episode)
            if e:
                listing.append(e)
                
    return listing