コード例 #1
0
    def req_video_list_sorted(self,
                              context_name,
                              context_id=None,
                              perpetual_range_start=None,
                              menu_data=None):
        """Retrieve a video list sorted"""
        # This type of request allows to obtain more than ~40 results
        common.debug(
            'Requesting video list sorted for context name: "{}", context id: "{}"',
            context_name, context_id)
        base_path = [context_name]
        response_type = 'stdlist'
        if context_id:
            base_path.append(context_id)
            response_type = 'stdlist_wid'

        # enum order: AZ|ZA|Suggested|Year
        # sort order the "mylist" is supported only in US country, the only way to query is use 'az'
        sort_order_types = [
            'az', 'za', 'su', 'yr'
        ] if not context_name == 'mylist' else ['az', 'az']
        req_sort_order_type = sort_order_types[int(
            g.ADDON.getSettingInt(
                'menu_sortorder_' +
                menu_data.get('initial_menu_id', menu_data['path'][1])))]
        base_path.append(req_sort_order_type)
        paths = build_paths(base_path + [RANGE_PLACEHOLDER],
                            VIDEO_LIST_PARTIAL_PATHS)

        path_response = self.netflix_session._perpetual_path_request(
            paths, [response_type, base_path], perpetual_range_start)
        return VideoListSorted(path_response, context_name, context_id,
                               req_sort_order_type)
コード例 #2
0
 def req_datatype_video_list_full(self,
                                  context_name,
                                  switch_profiles=False):
     """
     Retrieve the FULL video list for a context name (no limits to the number of path requests)
     contains only minimal video info
     """
     common.debug('Requesting the full video list for {}', context_name)
     paths = build_paths([context_name, 'az', RANGE_PLACEHOLDER],
                         VIDEO_LIST_BASIC_PARTIAL_PATHS)
     call_args = {
         'paths': paths,
         'length_params': ['stdlist', [context_name, 'az']],
         'perpetual_range_start': None,
         'request_size': PATH_REQUEST_SIZE_MAX,
         'no_limit_req': True
     }
     if switch_profiles:
         # Used only with library auto-update with the sync with Netflix "My List" enabled.
         # It may happen that the user browses the frontend with a different profile used by library sync,
         # and it could cause a wrong query request to nf server.
         # So we try to switch the profile, get My List items and restore previous
         # active profile in a "single call" to try perform the operations in a faster way.
         path_response = self.netflix_session._perpetual_path_request_switch_profiles(
             **call_args)
     else:
         path_response = self.netflix_session._perpetual_path_request(
             **call_args)
     return {} if not path_response else VideoListSorted(
         path_response, context_name, None, 'az')
コード例 #3
0
 def req_video_list_supplemental(self, videoid, supplemental_type):
     """Retrieve a video list of supplemental type videos"""
     if videoid.mediatype != common.VideoId.SHOW and videoid.mediatype != common.VideoId.MOVIE:
         raise common.InvalidVideoId('Cannot request video list supplemental for {}'.format(videoid))
     common.debug('Requesting video list supplemental of type "{}" for {}', supplemental_type, videoid)
     path = build_paths(
         ['videos', videoid.value, supplemental_type, {"from": 0, "to": 35}], TRAILER_PARTIAL_PATHS
     )
     path_response = self.netflix_session._path_request(path)
     return VideoListSorted(path_response, 'videos', videoid.value, supplemental_type)