Brawl345 / Get-DMAX-Links

Get links of Discovery shows and a specific season and/or episode
MIT License
21 stars 6 forks source link

Only 100 videos per show are processed #1

Closed birdie1 closed 4 years ago

birdie1 commented 4 years ago

You are only getting the first page of videos for a show. For example "fang-des-lebens-der-gefaehrlichste-job-alaskas" has 122 videos. Since the new api always need pagination, you should check for total amount of pages and get them too.

You could fix it like this (sorry i was to lazy to issue a pull request): new code: def get_videos_api_request(showid, token, page): try: req = get(SHOW_INFO_URL.format(showid, page), headers={"Authorization": "Bearer " + token}) except Exception as e: logger.critical("Connection error: {0}".format(str(e))) return False

if req.status_code != 200:
    logger.error("This show does not exist.")
    return False

data = req.json()
if "errors" in data:
    logger.error("This show does not exist.")
    return False

return data

Replacement for lines 83-96 in dmax.py: data = get_videos_api_request(showid, token, 1)

if data["meta"]["totalPages"] > 1:
    logger.info("More than 100 videos, need to get more pages")
    for i in range(1, data["meta"]["totalPages"]):
        more_data = get_videos_api_request(showid, token, i+1)
        data["data"].extend(more_data["data"])
Brawl345 commented 4 years ago

Thank you very much!