Has anything recently changed in the API
I have had a python program that has worked for months, but now it doesn't. I get the following error using a slimmed down version of original code. I would appreciate any help. Thank you!
Traceback (most recent call last):
File "Load - Copy2.py", line 50, in
Slimmed down code:
jw=JustWatch(country='US') #import pdb; pdb.set_trace() results = jw.search_for_item(providers='amp',content_types=['movie'],page=1,monetization_types=["flatrate"]) print('Done')
There's a PR (#31) out to update the search endpoint. JustWatch recently changed it
Thank you! Did they get rid of total_pages? Is there any other way to ensure you do not pull back too many records?
Thanks
Never mind. You guys are great! Thank you!
Sorry to be a pain, but I actually I take that back. "total_pages" no longer seems to be recognized. I want to perform an operation similar to #5 where I only want to loop through the # of pages that I pull back.
Thanks!
Not sure if it's a change, looks like total_pages is only available if you set the page size up front. You do always get total_results back, and you can keep requesting more pages until you get nothing returned. Or you can work out the number of pages from the total_results and the size of the first return. In example below there's 284 results and a default page size of 30. Page 10 has 14 results and Page 11 is empty
jw = JustWatch(country='GB')
just_watch = JustWatch(country='GB')
results = just_watch.search_for_item(query="mission",content_types=['movie'],page=1,page_size=4)
print(results['total_pages'])
print(results.keys())
71
dict_keys(['page', 'page_size', 'total_pages', 'total_results', 'items'])
results2 = just_watch.search_for_item(query="mission",content_types=['movie'])
print(results2.keys())
print(len(results2['items']))
print(results2['total_results'])
print(results2['items'][0]['title'])
dict_keys(['total_results', 'items'])
30
284
Mission: Impossible - Fallout
results2 = just_watch.search_for_item(query="mission",content_types=['movie'],page=2)
print(len(results2['items']))
print(results2['items'][0]['title'])
30
Nazi Overlord
results2 = just_watch.search_for_item(query="mission",content_types=['movie'],page=10)
print(len(results2['items']))
results2 = just_watch.search_for_item(query="mission",content_types=['movie'],page=11)
print(len(results2['items']))
14
0