Example #1
0
def _get_event_data(videoid):
    """Get data needed to send event requests to Netflix and for resume from last position"""
    is_episode = videoid.mediatype == common.VideoId.EPISODE
    req_videoids = [videoid]
    if is_episode:
        # Get also the tvshow data
        req_videoids.append(videoid.derive_parent(common.VideoId.SHOW))

    raw_data = api.get_video_raw_data(req_videoids, EVENT_PATHS)
    if not raw_data:
        return {}
    LOG.debug('Event data: {}', raw_data)
    videoid_data = raw_data['videos'][videoid.value]

    if is_episode:
        # Get inQueue from tvshow data
        is_in_mylist = raw_data['videos'][str(req_videoids[1].value)]['queue'].get('inQueue', False)
    else:
        is_in_mylist = videoid_data['queue'].get('inQueue', False)

    event_data = {'resume_position':
                  videoid_data['bookmarkPosition'] if videoid_data['bookmarkPosition'] > -1 else None,
                  'runtime': videoid_data['runtime'],
                  'request_id': videoid_data['requestId'],
                  'watched': videoid_data['watched'],
                  'is_in_mylist': is_in_mylist}
    if videoid.mediatype == common.VideoId.EPISODE:
        event_data['track_id'] = videoid_data['trackIds']['trackId_jawEpisode']
    else:
        event_data['track_id'] = videoid_data['trackIds']['trackId_jaw']
    return event_data
Example #2
0
 def rate_thumb(self, videoid):
     """Rate an item on Netflix. Ask for a thumb rating"""
     # Get updated user rating info for this videoid
     raw_data = api.get_video_raw_data([videoid],
                                       VIDEO_LIST_RATING_THUMB_PATHS)
     if raw_data.get('videos', {}).get(videoid.value):
         video_data = raw_data['videos'][videoid.value]
         title = video_data.get('title')
         track_id_jaw = video_data.get('trackIds', {})['trackId_jaw']
         is_thumb_rating = video_data.get('userRating',
                                          {}).get('type', '') == 'thumb'
         user_rating = video_data.get(
             'userRating',
             {}).get('userRating') if is_thumb_rating else None
         ui.show_modal_dialog(False,
                              ui.xmldialogs.RatingThumb,
                              'plugin-video-netflix-RatingThumb.xml',
                              G.ADDON.getAddonInfo('path'),
                              videoid=videoid,
                              title=title,
                              track_id_jaw=track_id_jaw,
                              user_rating=user_rating)
     else:
         LOG.warn(
             'Rating thumb video list api request no got results for {}',
             videoid)
Example #3
0
def get_info_from_netflix(videoids):
    """Get infolabels and arts from cache (if exist) or Netflix API, for multiple videoid"""
    profile_language_code = G.LOCAL_DB.get_profile_config('language', '')
    videoids_to_request = []
    info_data = {}
    for videoid in videoids:
        try:
            infos = get_info(videoid, None, None, profile_language_code)[0]
            art = _get_art(videoid, None, profile_language_code)
            info_data[videoid.value] = infos, art
            LOG.debug('Got infolabels and art from cache for videoid {}',
                      videoid)
        except (AttributeError, TypeError):
            videoids_to_request.append(videoid)

    if videoids_to_request:
        # Retrieve missing data from API
        LOG.debug('Retrieving infolabels and art from API for {} videoids',
                  len(videoids_to_request))
        raw_data = api.get_video_raw_data(videoids_to_request)
        for videoid in videoids_to_request:
            infos = get_info(videoid, raw_data['videos'][videoid.value],
                             raw_data, profile_language_code)[0]
            art = get_art(videoid, raw_data['videos'][videoid.value],
                          profile_language_code)
            info_data[videoid.value] = infos, art
    return info_data