Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rate limiting added for cleaning lists and infinite loop bug fixed #66

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions import_trakt.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def api_get_list(options, page):
if 'X-Pagination-Page-Count'in r.headers and r.headers['X-Pagination-Page-Count']:
print("Fetched page {page} of {PageCount} pages for {list} list".format(
page=page, PageCount=r.headers['X-Pagination-Page-Count'], list=options.list))
if page != int(r.headers['X-Pagination-Page-Count']):
if page < int(r.headers['X-Pagination-Page-Count']):
api_get_list(options, page+1)

return response_arr
Expand Down Expand Up @@ -276,6 +276,9 @@ def api_add_to_list(options, import_data):

def api_remove_from_list(options, remove_data):
"""API call for Sync / Remove from list"""
# 429 [AUTHED_API_POST_LIMIT rate limit exceeded. Please wait 1 seconds then retry your request.]
# Rate limit for API
time.sleep(1)
url = _trakt['baseurl'] + '/sync/{list}/remove'.format(list=options.list)
if options.type == 'episodes':
values = { 'shows' : remove_data }
Expand All @@ -299,7 +302,7 @@ def api_remove_from_list(options, remove_data):
def cleanup_list(options):
"""Empty list prior to import"""
export_data = api_get_list(options, 1)
if export_data:
if export_data != None:
print("Found {0} Item-Count".format(len(export_data)))
else:
print("Error, Cleanup no item return for {type} from the {list} list".format(
Expand Down