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

Add automatic yt-dlp update check #1

Merged
merged 6 commits into from
Aug 4, 2024
Merged

Add automatic yt-dlp update check #1

merged 6 commits into from
Aug 4, 2024

Conversation

nbtin
Copy link
Contributor

@nbtin nbtin commented Aug 3, 2024

Hi Lasith,

I've recently downloaded your plugin on Flow Launcher. This plugin is interesting. I love it!

After scrolling your GitHub repo, I found that your plugin is based on yt-dlp (actually a .exe file in your repo). I want to know what you intend to do if yt-dlp has its own updated version. Will you update the .exe file manually? I noticed that by the time I made this pull request, they had a newer version of it (2024.08.01) but your file is still 2024.07.25.

I suggest you fetch and download the yt-dlp.exe file directly from their repo (https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp.exe). And this process doesn't need to be conducted every time the app is triggered, I recommend you to set an interval (eg: 3 days, 1 week...) to check it automatically.

Have a good day!

@z1nc0r3
Copy link
Owner

z1nc0r3 commented Aug 3, 2024

Hi @nbtin

Thanks for the idea and the PR 🙌
However, I did some research and found that there is an Update option that we can pass as a parameter to the executable.

simply saying, that -U will update the executable itself before downloading the video.
yt-dlp -U [other options]

@nbtin
Copy link
Contributor Author

nbtin commented Aug 3, 2024

Ohh, I didn't realize that, hehe. Thanks for letting me know, keep up the good work @z1nc0r3 !

Copy link
Owner

@z1nc0r3 z1nc0r3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about just adding -U flag to the current command variable.

command = f"yt-dlp -f {format_id}+ba {url} -P ~/Downloads/AnyDownloader -U --windows-filenames --quiet --progress --no-mtime --force-overwrites --no-part"

So it automatically checks and updates itself when the user tries to download videos if there is a new version.
wdyt?

@nbtin
Copy link
Contributor Author

nbtin commented Aug 3, 2024

Totally get it! 😸

It's just different perspectives on the same issue. Adding the -U flag into the current command variable is a good way to simplify the code 👍. However, I just wonder if it needs to wait a bit for checking updates every time users want to download a video. I think it's a trade-off here.

In my opinion, nobody likes surprise updates when they're just trying to grab a funny cat video 😂. So, I think setting time intervals would make things less 'Windows Update-y', and users only update the first time running in a day (after a while)...

Copy link
Owner

@z1nc0r3 z1nc0r3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, got the idea 😉

Anyway, I have some suggestions for making the code as simple as possible.

  • One thing noticed is here it seems to open a separate terminal for the update process, which may conflict with the actual download terminal. Because both trying to use the same executable file.
  • So, maybe we can move the checking for the update function call to the download function, just after the command variable. And append the -U flag to the already existing command.
  • And the last thing is the logic behind the getting last day. I think we can use something like os.path.getmtime(file_path) to get the last modified date of the .exe file and compare it with today and take a decision.

Need your suggestions on this. And sorry to ask for lots of reviews 😅

@nbtin
Copy link
Contributor Author

nbtin commented Aug 4, 2024

A LOT OF good reviews help us code better =)) I'm okay with that, hehe.
Anyway, your suggestions are lit :)) My code is quite complicated 😅. Maybe I'm overthinking 😆.
I have changed the code a bit, take a look bro @z1nc0r3

@nbtin nbtin requested a review from z1nc0r3 August 4, 2024 06:23
Copy link
Owner

@z1nc0r3 z1nc0r3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks Awesome! Thanks 🙌

@z1nc0r3 z1nc0r3 merged commit e08d6b6 into z1nc0r3:main Aug 4, 2024
@z1nc0r3 z1nc0r3 added the enhancement New feature or request label Aug 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants