Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Option to download the current episode from episode control menu #91

Closed
Prashanthvsdvn opened this issue Oct 12, 2022 · 10 comments

Comments

@Prashanthvsdvn
Copy link

There are times when the internet connection is unstable and stream keeps buffering. It would be handy if there was an option in the Now Playing menu to download the current episode instead.

The current workaround is to either print the stream url and use yt-dlp to download the file but then manually rename and move.
Or exit the current session and open it in Download Mode and search for the episode to download. Both of which are slight annoyance to accomplish the task.

sdaqo added a commit that referenced this issue Oct 12, 2022
@sdaqo
Copy link
Owner

sdaqo commented Oct 12, 2022

A good idea. Implemented it. I also implemented a option you can set (auto_open_dl_defaultcli) in the config that auto opens the file after the download. Have fun.

@Prashanthvsdvn
Copy link
Author

Hey! Thanks for the immediate commit. The download option works as intended. However, the option to auto open after download doesn't.

Sadly, I don't have any trace back or outputs that I can post it for debugging. It just doesn't auto opens after download.

However, when I try to re-download the episode, I can see Skipping already existing for a split second.
Let me know, if I can do anything to sort this issue out and we can close this.

@VoidAny
Copy link
Contributor

VoidAny commented Oct 12, 2022

However, when I try to re-download the episode, I can see Skipping already existing for a split second.

So, the downloading feature works. You got this message because the anime you were trying to download was already in you downloads file.

@sdaqo
Copy link
Owner

sdaqo commented Oct 12, 2022

Yes, the player is probably not opening because either the option is not correctly set in the config or it's a windows problem, since it works fine on my Linux machine.

@VoidAny
Copy link
Contributor

VoidAny commented Oct 12, 2022

@Prashanthvsdvn can you send us your config file?

@Prashanthvsdvn
Copy link
Author

However, when I try to re-download the episode, I can see Skipping already existing for a split second.

So, the downloading feature works. You got this message because the anime you were trying to download was already in you downloads file.

Yes, I was just trying to trigger the auto play option after the download.

@Prashanthvsdvn
Copy link
Author

@Prashanthvsdvn can you send us your config file?

anipy_cli_folder : 'C:\Users\Prashanth\.anipy-cli'
download_folder_path : 'D:\Videos\Anime'
download_name_format : '{show_name}_{episode_number}.mp4'
download_remove_dub_from_folder_name : False
dc_presence : True
player_path: 'mpv'
auto_open_dl_defaultcli: True

@VoidAny
Copy link
Contributor

VoidAny commented Oct 12, 2022

I figured out the issue:

    def download_video(self):
        try:
            path = download(self.entry).download()
            if Config().auto_open_dl:
                player_command = ["mpv", str(path)]
                if os.name in ("nt", "dos"):
                    sp.Popen(player_command)
                else:
                    sp.Popen(player_command, stdout=sp.PIPE, stderr=sp.DEVNULL)

        except: #TODO: Make some error for download fail
            pass

        self.print_status()
        self.print_opts()

Above is the newly implemented function that is called when d is used in the cli interface. The issue with it is that Config().auto_open_dl does not exist. It is actually Config().auto_open_dl_defaultcli. Also, the string "mpv" is used instead of Config().player_path. The reason why an exception is not raised when using this is because this part of the code is in a try except statement that has an empty except part. This catches the error so it is harder to understand why this is not working. @sdaqo please avoid writing try except statements that don't catch explicit exceptions in the future. Also consider using a linter for python so you can see when you are using variables that don't exist.

sdaqo added a commit that referenced this issue Oct 13, 2022
Fix issue with download_video function from issue #91
@sdaqo
Copy link
Owner

sdaqo commented Oct 13, 2022

True, I committed the change to the property name in a separate commit without changing it in the if statement, to that's probably why it worked for me before.

@Prashanthvsdvn
Copy link
Author

Just tested out the change. The playback after downloading works. Closing the issue. Thank you both of you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants