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 --yes-overwrites option #20405

Closed
wants to merge 2 commits into from
Closed

Add --yes-overwrites option #20405

wants to merge 2 commits into from

Conversation

alxnull
Copy link

@alxnull alxnull commented Mar 18, 2019

Before submitting a pull request make sure you have:

In order to be accepted and merged into youtube-dl each piece of code must be in public domain or released under Unlicense. Check one of the following options:

  • I am the original author of this code and I am willing to release it under Unlicense
  • I am not the original author of this code but it is in public domain or released under Unlicense (provide reliable evidence)

What is the purpose of your pull request?

  • Bug fix
  • Improvement
  • New extractor
  • New feature

Description of your pull request and other information

Edit: Resolves #23034.

Currently, if a file with the same name already exists, the download of a video ends with this message, saying it's been downloaded already (be aware that this behaviour does not change by adding the --no-continue flag):

youtube-dl --no-continue https://www.youtube.com/watch?v=_QdPW8JrYzQ

[youtube] _QdPW8JrYzQ: Downloading webpage
[youtube] _QdPW8JrYzQ: Downloading video info webpage
[download] This is what happens when you reply to spam email _ James Veitch-_QdPW8JrYzQ.webm has already been downloaded and merged

However, to my understanding, without the --no-overwrites flag which explicitly enforces such behaviour, all downloaded files should be overwritten (thus redownloaded). That's already the case e.g. for info jsons, video descriptions or subtitles but not for video files themselves.

If this is an unwanted behaviour, I could add an optional flag (--force-overwrites) to implement it solely for video files. I currently did not do that because I think it would make the available options more confusing.

(This issue was raised e.g. in #14031 a while ago)

@alxnull
Copy link
Author

alxnull commented May 5, 2019

@dstftw or @remitamine as it seems you're the main developers on this project, I'd be really glad to receive some feedback from you on this.

@dstftw
Copy link
Collaborator

dstftw commented May 5, 2019

I definitely won't accept current solution as it breaks the default behavior. Media files are considered big files and should not be overwritten until explicitly told to do so. I also won't accept --force-overwrites.

What I probably will accept is extending overwrites options to:

  • No overwrites option defined - current default behavior, don't overwrite media files
  • --no-overwrites - no overwrites for any file
  • --yes-overwrites - overwrites for any file

Everything should be covered with tests.

@DaveF63
Copy link

DaveF63 commented Aug 13, 2019

Until this essential command is added, could someone inform me:
a) Where the record of downloaded files is stored.
b) Why does this appear to only occur with merged files. If I use -f best it overwrites quite happily.

@alxnull
Copy link
Author

alxnull commented Oct 13, 2019

As suggested by @dstftw, I added a new --yes-overwrites option, leaving the default behaviour untouched. As the available options and their consequences can get quite confusing now, here's a quick overview how the overwrite-related options behave in some cases (tested w. 2019.09.28 using a Youtube video):

Additional options default --no-overwrites --no-continue --yes-overwrites
no options ✔️
-f best ✔️/ ❌ ✔️
-x/ --recode-video mp4 ✔️ ✔️ ✔️ ✔️
Metadata (e.g. --write-thumbnail) ✔️ ✔️ ✔️

(❌: no overwrite; ✔️: overwrite)

@alxnull alxnull changed the title Overwrite merged video without no-overwrites flag Add --yes-overwrites option Oct 13, 2019
@wangqr wangqr mentioned this pull request Nov 10, 2019
6 tasks
@section83
Copy link

Can this change be implemented ? It would greatly help. Thanks.

@ghost
Copy link

ghost commented Feb 14, 2020

I was also looking for such a feature too right now, I downloaded 720p, but I decided to use 1080p quality with another command, but I have to go navigate to the disk to delete it manually.

I do understand that it's better to be safe and not overwrite by accident, but in such a case where I know I don't need the old version and I'm really sure then why not have such an option. Thanks

@section83
Copy link

section83 commented Feb 14, 2020

I do understand that it's better to be safe and not overwrite by accident, but in such a case where I know I don't need the old version and I'm really sure then why not have such an option.

Yes, it's good to know YTDL will never over-write. Those of us who use YTDL in our projects just have to build our own code to find duplicates and ask the user what to do. Challenge for me has been working out exactly what YTDL does.

@alxnull alxnull force-pushed the patch-1 branch 4 times, most recently from 42ada3f to 73975ec Compare March 30, 2020 22:00
@alxnull
Copy link
Author

alxnull commented Mar 31, 2020

No overwrites option defined - current default behavior, don't overwrite media files
--no-overwrites - no overwrites for any file
--yes-overwrites - overwrites for any file

@dstftw Implemented as you suggested and added a test. Please review. Thanks!

@dstftw dstftw force-pushed the master branch 2 times, most recently from 5e26784 to da2069f Compare September 13, 2020 13:50
@subirax
Copy link

subirax commented Oct 1, 2020

I just tested this and sadly, it doesn't work -- "no such option" with the latest update, 2020.09.20.
Here is the complete output of the attempt. What am I doing wrong?

============
youtube-dl --yes-overwrites https://www.dailymotion.com/video/x17jdp7
Usage: youtube-dl [OPTIONS] URL [URL...]

youtube-dl: error: no such option: --yes-overwrites

I hope this is helpful.
Thanks!

@solbu
Copy link

solbu commented Oct 1, 2020

@subirax
I just tested the same, and it works.
Did you apply the patch?

Remember this Pull Request it isn't merged into the code yet, so you need to apply the patch before compiling/testing.

@Arnauw
Copy link

Arnauw commented Jan 9, 2021

Hello I have last version and "--yes-overwrites" doesn't work, is it possible to fix it or something ?
Or can you tell me how to force overwrite please ?

@ghost
Copy link

ghost commented Jan 11, 2021

@Arnauw As stated above, this is still open, it's not merged yet, it's not part of youtube-dl yet, you would need to compile it with this patch yourself in the meantime while it gets all the tests/checks done to get in.

@Arnauw
Copy link

Arnauw commented Jan 11, 2021

@altimumdelta Ok thanks ;)

pukkandan pushed a commit to yt-dlp/yt-dlp that referenced this pull request Jan 12, 2021
@darbdenral
Copy link

The exe for Windows downloaded today youtube-dl version 2021.06.06 gives the same error..
youtube-dl.exe: error: no such option: --yes-overwrites

@Serene-Arc
Copy link

Is this PR still active? Was considering coding a PR to do the same thing but this one looks like it would fulfill my use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defunct PR source branch is not accessible pending-fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Force Overwrite
10 participants