justfoolingaround / animdl

A highly efficient, fast, powerful and light-weight anime downloader and streamer for your favorite anime.
GNU General Public License v3.0
1.31k stars 108 forks source link

How to prefer no/soft subtitles? #96

Closed Munzu closed 2 years ago

Munzu commented 2 years ago

How do I tell animdl to prefer no/soft subtitles?

Background: I'd like to use animdl for my Japanese immersion learning and stream anime without any subtitles so I can inject my own Japanese subtitle files into MPV. I was planning to use zoro since I believe it was the only source available that provides videos that don't have the subtitles baked into them.

I scanned over the code and it seems the intelliq.py file is responsible for parsing the quality string but I couldn't figure out how to deal with subtitles.

Could you tell me if/how this can be done? Thanks in advance.

justfoolingaround commented 2 years ago

You see only the hard-subbed streams from Zoro are actually extracted by the project. This would mean that the only subtitle-less source is Crunchyroll.

You can always use Crunchyroll with best[subtitle] as the quality to select the stream with soft subtitles.

Munzu commented 2 years ago

Thanks for the quick reply!

Unfortunately, I can't watch a lot of anime on Crunchyroll because they aren't available in my country and I don't have a VPN at the moment.

You see only the hard-subbed streams from Zoro are actually extracted by the project.

Could you tell me where in the code I could modify that behavior? I'd like to try and contribute but I haven't quite understood the project's file structure yet.

justfoolingaround commented 2 years ago

Unfortunately, I can't watch a lot of anime on Crunchyroll because they aren't available in my country and I don't have a VPN at the moment.

The project uses a geo-bypass to view from the American library.

Could you tell me where in the code I could modify that behavior? I'd like to try and contribute but I haven't quite understood the project's file structure yet.

Even if I do it, it isn't like it is an intended behaviour. The soft subbed streams are reCaptcha gated and hence, cannot be extracted at all. The only reason Zoro is in the project's list of providers is because of the streams that aren't reCaptcha gated but are soft-subbed unfortuantely.

Munzu commented 2 years ago

Oh I see, that's unfortunate but good to know.

The project uses a geo-bypass to view from the American library.

In that case it seems to be misbehaving for me. When I search for "crunchyroll:konosuba", it says "Now initiating your stream session" and crashes soon after without any further message. I originally assumed that was because of the geo restriction because it's not available but I just tested it with a series that is available for me (non non biyori) and got the same behavior unfortunately.

python -m animdl stream "crunchyroll:konosuba"
                        justfoolingaround/animdl - v1.4.35                        
                 A highly efficient anime downloader and streamer                 
[processors.py:15 - 2022-01-07 18:38:44,640 - streamer: I] 01: KONOSUBA -God's blessing on this wonderful world! https://www.crunchyroll.com/de/konosuba-gods-blessing-on-this-wonderful-world
[stream.py:104 - 2022-01-07 18:38:44,640 - crunchyroll/streamer: I] Now initiating your stream session

Should I make a separate bug report for this?

justfoolingaround commented 2 years ago

Can you try:

animdl stream https://www.crunchyroll.com/konosuba-gods-blessing-on-this-wonderful-world

?

Munzu commented 2 years ago

Thank you! That does open the MPV and it plays but it doesn't let me choose the season and autoplays "KONOSUBA -God's blessing on this wonderful world!- Legend of Crimson", which is the movie.

If I append -r <number>, it plays the respective episode of the English dub of the first season. The season has 10 episodes. I then thought maybe if I put -r 11, I get the first episode of the next season but that just throws this error:

                        justfoolingaround/animdl - v1.4.35                        
                 A highly efficient anime downloader and streamer                 
[stream.py:104 - 2022-01-07 19:10:43,703 - crunchyroll/streamer: I] Now initiating your stream session
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/tai/.local/lib/python3.10/site-packages/animdl/__main__.py", line 34, in <module>
    __animdl_cli__()
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/tai/.local/lib/python3.10/site-packages/animdl/core/cli/helpers/fun.py", line 135, in internal
    return f(*args, **kwargs)
  File "/home/tai/.local/lib/python3.10/site-packages/animdl/core/cli/commands/stream.py", line 109, in animdl_stream
    streams = list(enqueuer)
  File "/home/tai/.local/lib/python3.10/site-packages/animdl/core/codebase/providers/crunchyroll/__init__.py", line 62, in fetcher
    for episode_number, episode_data in sorted(group_content(slug, htmlparser.fromstring(geobypass_response(url).text)).items()):
  File "/home/tai/.local/lib/python3.10/site-packages/animdl/core/codebase/providers/crunchyroll/geobypass.py", line 26, in geobypass_response
    'session_id': get_session_id()})
  File "/home/tai/.local/lib/python3.10/site-packages/animdl/core/codebase/providers/crunchyroll/geobypass.py", line 20, in get_session_id
    return httpx.get(BYPASS_SERVER, params={'version': '1.1'}).json().get(
  File "/home/tai/.local/lib/python3.10/site-packages/httpx/_models.py", line 1432, in json
    return jsonlib.loads(self.content.decode(encoding), **kwargs)
  File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Interestingly, setting anything higher than 11 just crashes it without any further message. I only got this error with -r 11

I also tried pasting the link for Non Non Biyori. No matter what link I give it, animdl always defaults to the first episode of the first season with Japanese dub. If I append -r <number> to this, it plays the respective episode of the first season, which has 12 episodes, but if I put 12 or higher, it crashes without any further message.

In short, the only thing I seem to be able to specify is the episode number of whatever season animdl defaults to.

justfoolingaround commented 2 years ago

It is because the page contained nothing to scrape, probably due to premium episodes?

Overall just use

$ animdl stream https://www.crunchyroll.com/konosuba-gods-blessing-on-this-wonderful-world -q "[title=r'KONOSUBA -God.s blessing on this wonderful world! 2']"

to select seasons. I'm sorry but this is one of the few limitations of Crunchyroll support.
titles For titles, just go to the respective site and grab the title from the header!

justfoolingaround commented 2 years ago

Since the original problem was solved, I'll be closing this!