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.32k stars 109 forks source link

Streaming in current instance of mpv using named pipe or include anime title in grab json output #169

Open toomyzoom opened 2 years ago

toomyzoom commented 2 years ago

From maintainers: Both labels have been handed to this issue, remove the inapplicable one. Your title should answer at least 3 of 5W1H questions for fastest responses.

Is your feature request related to a problem? Please describe.

So currently, animdl is opening/closing instance for every video when using stream command in start_streaming_mpv() function. This is a problem for me because:

  1. The instance I set up using input-ipc-server switch to create a named pipe in order to control/add file to the current instance without closing it. Opening and closing for every video are not efficient while all videos can just be queued to the current playlist.
  2. I'm running mpv without desktop manager/environment. An xinit instance was spawning the mpv instance. When I tried to use streaming using mpv through animdl, the change refreshrate script I have doesn't work because it needed to be run in X session to use xrandr.
  3. I tried to use config.yml to run mpv with xinit but it seems I can't get it to work properly.

So I tried to use grab and parsing the json output to feed it to my mpv instance through ipc socket. This approach was acceptable but the json only contains the episode and stream_url fields. I need something to get the series name like animdl search --json <name> output to set the title correctly like how it was done in start_streaming_mpv()

I need this because I use something similar to #86.

There are currently 2 approaches that I consider appropriate:

Describe the solution you'd like

Describe alternatives you've considered

Additional context

Modifying the grab command to output the series name is likely less work than the stream command suggestion.

toomyzoom commented 2 years ago

Oof, fixed as of 1.6.21. Thank you for reporting this issue.

Details:

Cause of error: Inverted logical operator. Expected outcome: No banner in log level higher than 20. Unfixed outcome; No banner in log level lesser than 20. Fixed version: 1.6.21

I think you mean this reply for #168

toomyzoom commented 2 years ago

I modified grab.py, animdl_grab function

def animdl_grab(query, index, log_level, **kwargs):

    r = kwargs.get("range")

    logger = logging.getLogger("grabber")
    anime, provider = helpers.process_query(
        client, query, logger, auto_index=index, provider=DEFAULT_PROVIDER
    )

    if not anime:
        return

    logger.name = "{}/{}".format(provider, logger.name)
    logger.info("Initializing grabbing session.")

    for stream_url_caller, episode in providers.get_appropriate(
        client, anime.get("anime_url"), check=r
    ):
        stream_url = list(helpers.ensure_extraction(client, stream_url_caller))
        click.echo(json.dumps({"title": anime.get("name") + ' ' + str(episode), "episode": episode, "streams": stream_url}))

    logger.info("Grabbing session complete.")

This change is at line:

<         click.echo(json.dumps({"episode": episode, "streams": stream_url}))
---
>         click.echo(json.dumps({"title": anime.get("name") + ' ' + str(episode), "episode": episode, "streams": stream_url}))

This will show the title with episode number just like how you did it in stream.py in b1b74a98645174dbacf84d36b43ff6b056745094