wolfswolke / aniworld_scraper

Aniworld.to mp4 scraper for animes.
MIT License
49 stars 16 forks source link

[BUG] Code crashing when a download is not available #21

Closed TrackLab closed 9 months ago

TrackLab commented 9 months ago

Describe the bug: So, when VEO has a video not available due to maintenance mode or whatever, the code crashes.

Steps to Reproduce the bug: Download a series, if a video is not available by VOE, the code cant handle it

Expected behavior: A NoneType Attribute Error is thrown and the code stops

Additional Info A quick way to fix it, which I quickly implemented myself: Give the find_cache_url function in search_for_links.py a try/except for the provider check. Like so:

    try:
        if provider == "Vidoza":
            soup = BeautifulSoup(html_page, features="html.parser")
            cache_link = soup.find("source").get("src")
        elif provider == "VOE":
            cache_link = VOE_PATTERN.search(html_page.read().decode('utf-8')).group("url")
        elif provider == "Streamtape":
            cache_link = STREAMTAPE_PATTERN.search(html_page.read().decode('utf-8'))
            if cache_link is None:
                return find_cache_url(url, provider)
            cache_link = "https://" + provider + ".com/" + cache_link.group()[:-1]
            logger.debug(MODULE_LOGGER_HEAD + f"This is the found video link of {provider}: {cache_link}")
    except:
        return None

And then use that returned None in the start_app.py Mainfunction, to check if the returned cache_url is None. If it is not, initiate the download. if it is none, print a statement, to inform the user which season/episode could not be downloaded. Like so:

if cache_url is not None:
                    create_new_download_thread(cache_url, file_name, provider)
                else:
                    print(f"COULD NOT DOWNLOAD! Season: {season} Episode {episode}")

The code can then simply continue onto the text episode.

I can fork the project and implement the fix myself if you want.

wolfswolke commented 9 months ago

@TrackLab sorry for the late response. I implemented a code to "fix" this. Does this only happen when vidoza has maintenance? Or are there any animes where you know it happens all the time?

wolfswolke commented 9 months ago

Issue should be resolved with latest Release. Please try again and open another Issue if its not. Thank you for bringing this to my attention.

TrackLab commented 8 months ago

@TrackLab sorry for the late response. I implemented a code to "fix" this. Does this only happen when vidoza has maintenance? Or are there any animes where you know it happens all the time?

it was when VOE is in maintenance mode, since that was the first attempt by the software. Oh also, you have a typo in your logging. In the "please download manually later". it says "please download manly later"