Skip to content

Commit 483e10a

Browse files
authored
Merge pull request #11 from Ruud68/mylist
fix for my list
2 parents d0bd8a3 + 622782e commit 483e10a

1 file changed

Lines changed: 31 additions & 14 deletions

File tree

resources/lib/services/nfsession/directorybuilder/dir_path_requests.py

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,8 @@ def _normalize_browser_video_fields(path_response):
655655
if not isinstance(video, dict):
656656
continue
657657
item_summary = item_summaries.get(str(video_id), {})
658+
if not item_summary:
659+
item_summary = video.get('itemSummary', {}).get('value', {})
658660
if item_summary:
659661
video.setdefault('itemSummary', _value(item_summary))
660662
_set_browser_boxart(video, item_summary)
@@ -1197,20 +1199,35 @@ def _browser_mylist_direct_video_list(self, list_id, auth_url):
11971199
raise InvalidVideoListTypeError('No current direct My List content available')
11981200

11991201
def _browser_mylist_video_list(self):
1200-
root_id, auth_url = self._get_current_loco_root_id()
1201-
list_id, row_key = self._browser_mylist_list_info(root_id, auth_url)
1202-
if row_key is not None:
1203-
try:
1204-
video_list = self._browser_mylist_loco_video_list(root_id, row_key, list_id, auth_url)
1205-
except InvalidVideoListTypeError:
1206-
LOG.warn('Falling back to direct My List request after LoCo row content lookup failed')
1207-
video_list = self._browser_mylist_direct_video_list(list_id, auth_url)
1208-
else:
1209-
video_list = self._browser_mylist_direct_video_list(list_id, auth_url)
1210-
for video in video_list.videos.values():
1211-
video.setdefault('queue', _value({}))
1212-
video['queue'].setdefault('value', {})['inQueue'] = True
1213-
return video_list
1202+
browse_bytes = self.nfsession.get_safe('browse')
1203+
api_data = self.nfsession.website_extract_session_data(browse_bytes)
1204+
auth_url = api_data['auth_url']
1205+
self.nfsession.auth_url = auth_url
1206+
return self._browser_mylist_path(auth_url)
1207+
1208+
def _browser_mylist_path(self, auth_url):
1209+
"""Fetch My List via browser pathEvaluator using the mylist Falcor path"""
1210+
paths = [
1211+
['mylist', ['id', 'listId', 'name', 'requestId', 'trackIds']],
1212+
['mylist', BROWSER_LOCO_DIRECT_RANGE,
1213+
['availability', 'episodeCount', 'inRemindMeList', 'itemSummary', 'queue', 'summary']]
1214+
]
1215+
path_response = self._post_current_loco_paths(paths, auth_url)
1216+
mylist = path_response.get('mylist', {})
1217+
if not mylist:
1218+
raise InvalidVideoListTypeError('No mylist data in browser path response')
1219+
# VideoListSorted (context_id=None) expects path_response[context_name][sort_key],
1220+
# so wrap the mylist dict under an 'items' sub-key.
1221+
# iterate_references (used by resolve_refs) ignores non-numeric keys automatically,
1222+
# so refs and metadata atoms coexist safely in the same dict.
1223+
synthetic = {
1224+
'mylist': {
1225+
'items': mylist,
1226+
'trackIds': mylist.get('trackIds', _value({})),
1227+
},
1228+
'videos': path_response.get('videos', {})
1229+
}
1230+
return VideoListSorted(synthetic, 'mylist', None, 'items')
12141231

12151232
def _browser_lolomo_video_list_by_id(self, category_name, list_id):
12161233
self._browse_html_and_auth_url()

0 commit comments

Comments
 (0)