animdl icon indicating copy to clipboard operation
animdl copied to clipboard

Animdl exits with error on non-integer episode number

Open Turtyo opened this issue 2 years ago • 3 comments

Describe the bug

I was trying earlier to download some anime (as we do with animdl), and when trying the following : animdl download -d $VID/../../anime/ -q 720 -r 3-24 'animeout:Sword Art Online: Alicization' I got this error : ValueError: invalid literal for int() with base 10: '18.5'

Did the error occur in between an active task (download / stream / grab)?

This was during the scrapping part

Screenshots [Optional] Not really screenshots but here is the reason for the bug : animeout labeled one episode as 18.5 (a recap episode if I remember correctly from last time I watched). The error log shows why there is this error :

/home/my_name/.local/lib/python3.10/site-packages/animdl/core/codebase/helpers/__init__.py:54 in  │
│ parse_from_content                                                                               │
│                                                                                                  │
│   51 │   │   if isinstance(episode_number, list):                                                │
│   52 │   │   │   episode_number = episode_number[0]                                              │
│   53 │   │                                                                                       │
│ ❱ 54 │   │   returnee.update({"episode": int(episode_number or 0)})                              │
│   55 │                                                                                           │
│   56 │   if isinstance(video_res, str):                                                          │
│   57 │   │   stripped = video_res.strip("p")                                                     │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │       anitopy_result = {                                                                     │ │
│ │                        │   'file_name': '[AnimeOut] Sword Art Online Alicization - 18.5 -    │ │
│ │                        Recollection[1080pp][KH][RapidB'+7,                                   │ │
│ │                        │   'file_extension': 'mkv',                                          │ │
│ │                        │   'video_resolution': '1080p',                                      │ │
│ │                        │   'episode_number': '18.5',                                         │ │
│ │                        │   'anime_title': 'Sword Art Online Alicization',                    │ │
│ │                        │   'release_group': 'AnimeOut',                                      │ │
│ │                        │   'episode_title': 'Recollection'                                   │ │
│ │                        }                                                                     │ │
│ │              content = URL('http://nimbus.animeout.com/series/00RAPIDBOT/Sword%20Art%20Onli… │ │
│ │       episode_number = '18.5'                                                                │ │
│ │       episode_parsed = False                                                                 │ │
│ │       name_processor = <function fetcher.<locals>.<genexpr>.<lambda> at 0x7fda157c6830>      │ │
│ │            overrides = {}                                                                    │ │
│ │             returnee = {                                                                     │ │
│ │                        │   'stream_url': 'http://pub9.animeout.com/series/00RAPIDBOT/Sword   │ │
│ │                        Art Online Alicization/[AnimeOu'+79                                   │ │
│ │                        }                                                                     │ │
│ │ stream_url_processor = <function animeout_stream_url at 0x7fda153376d0>                      │ │
│ │            video_res = '1080p'

As we can see, the episode number is 18.5. I think this is a marginal issue, it doesn't happen often, but that's still a bit frustrating. Maybe putting an option to ignore these "half" episode would solve the problem. The main thing here is that animdl will straight up refuse to download any episode because one of them has an incorrect number.

Additional information

  • animdl, version 1.7.12
  • provider is animeout

I also tried to use animdl download -d $VID/../../anime/ -q 720 -r 3-17,19-24 'animeout:Sword Art Online: Alicization' and animdl download -d $VID/../../anime/ -q 720 -r 3-17 'animeout:Sword Art Online: Alicization' but that didn't work either.

Turtyo avatar Apr 20 '23 08:04 Turtyo

While I'm at it, here is the temporary fix that I did:

    if not episode_parsed:

        episode_number = anitopy_result.get("episode_number", 0)

        if isinstance(episode_number, list):
            episode_number = episode_number[0]
        try: 
            returnee.update({"episode": int(episode_number or 0)})
        except:
            return returnee

I'm not sure if this would work all the time because I'm not familiar enough with the code of the project but at least i was able to download the episode 3. I think this downloaded in 1080 instead of 720 considering the size of the video file, so definitely not a good fix.

Turtyo avatar Apr 20 '23 08:04 Turtyo

Hi, I'm also having this issue. Were you able to find a better fix? Either way, where and in what file did you add this code? Thanks.

zilqnova avatar Jun 29 '23 19:06 zilqnova

Sorry, I forgot to mention the file. It's the same file as the one mentioned in the error, ie /home/my_name/.local/lib/python3.10/site-packages/animdl/core/codebase/helpers/__init__.py. This may differ depending on your system. I replaced the lines 51 to 54 by the code above. It will just ignore recap episodes, and ignoring the problem instead of fixing the root issue is not a good fix, but it works for now.

Turtyo avatar Oct 11 '23 09:10 Turtyo