Skip to content

Conversation

@tpikonen
Copy link
Contributor

Get the output file name from the yt-dlp result dict and rename the file to what is expected (tempname), if it is different.

Add the extension to the output template. This is needed to unbreak post-processing (like subtitle embedding). See yt-dlp issue 1844.

Set the 'paths' param in ydl to get all downloaded files to the correct location.

In addition, the first commit makes util.sanitize_filename_ext() to return a file name without an ending perdiod, if ext is empty.

@auouymous
Copy link
Member

It still spams WARNING: --paths is ignored since an absolute path is given in output template to console after every download. Do you see any issues with setting outtmpl to os.path.basename(tempname) + '.%(ext)s'?

@auouymous
Copy link
Member

We also need to decide if youtube-dl support should be dropped or if this patch needs to be modified to use the old renaming code for youtube-dl, and new code for yt-dlp. youtube-dl doesn't support --paths, or complain about it, but outtmpl would need the absolute path for it to work. Then there is the renaming code that uses the unsupported filepath in youtube-dl. I'd say drop it due to no releases this year, but it does appear active and might get a release eventually.

@tpikonen
Copy link
Contributor Author

tpikonen commented Sep 3, 2022

Do you get the '--paths' warnings only with youtube-dl (not yt-dlp)? Admittedly I did not test with youtube-dl.

The support for original youtube-dl could be dropped, IMO.

@auouymous
Copy link
Member

Do you get the '--paths' warnings only with youtube-dl (not yt-dlp)?

Only yt-dlp throws the warning, for every download. youtube-dl doesn't know about it and has no code to warn.

The support for original youtube-dl could be dropped, IMO.

There is a chance that some distro doesn't have yt-dlp yet and would cause problems for users. We could drop it in January if they don't get a release out this year, but it might be good to continue supporting it until then.

There is a new program_name variable that could be used to switch code.

@tpikonen
Copy link
Contributor Author

tpikonen commented Sep 3, 2022

Strangely I don't see the warning here, although when looking at yt-dlp code I should. There should be no problem in using os.path.basename(tempname) + '.%(ext)s' as outtmp.

I'll look into switching the rename code on program_name.

…empty

Prevents file names with two periods before the extension.
@tpikonen
Copy link
Contributor Author

tpikonen commented Sep 3, 2022

Now has separate renaming for yt-dlp and youtube-dl, uses os.path.basename(tempname) and only adds '.%(ext)s' for yt-dlp.

Rebased to master, needs squashing later.

@tpikonen
Copy link
Contributor Author

tpikonen commented Sep 3, 2022

I only tested this with yt-dlp, so please test with youtube-dl.

@elelay
Copy link
Member

elelay commented Sep 5, 2022

Not tested, but code looks good. Thanks!

@auouymous auouymous linked an issue Oct 27, 2022 that may be closed by this pull request
@auouymous
Copy link
Member

I'll merge it in a week if nothing breaks during testing.

@tpikonen
Copy link
Contributor Author

tpikonen commented Nov 7, 2022

I'll merge it in a week if nothing breaks during testing.

Great, I'll squash this before that.

Use separate code paths to rename output files from yt-dlp and
youtube-dl to the requested name ('tempname'). The output is always
renamed with yt-dlp.

Add the 'ext' to the output template. This is needed to unbreak
post-processing (like subtitle embedding). See yt-dlp issue #1844.

Use basename(tempname) for yt-dlp and tempname for youtube-dl as output
template, since we set the output path for yt-dlp in the 'paths' option.
Derive abstract classes CustomDownload and CustomDownloader from ABC
from the abc module. Decorate abstract methods with @AbstractMethod.

Add abstract 'partial_filename' property to CustomDownload and make it
concrete in the derived DefaultDownload class. This property holds the
full path of the temporary file where the episode is being downloaded
or None, if the downloader does not use a previewable temporary file.
Add the 'partial_filename' property for a previewable temporary file.

Get this filename from yt-dlp / youtube-dl by splitting the download
into two parts, first get the extractor info which contains the 'ext',
derive the temporary filename from that and the outtmpl and then
download the file.
Add 'custom_downloader' member var to DownloadTask. Use it in
episode.get_playback_url() to get a preview file name.

Also add episode.can_preview() method and use it in ep.can_play().
Use it to decide if 'Preview' is shown in episode contect menu.
@auouymous auouymous merged commit 1b9ed37 into gpodder:master Nov 14, 2022
auouymous added a commit to auouymous/gpodder that referenced this pull request Nov 22, 2022
PR gpodder#1382 broke support for yt-dlp versions prior to 2022.6.22.1.

Fixes gpodder#1439.
@tpikonen tpikonen deleted the ytdl-rename branch August 22, 2023 14:19
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

Successfully merging this pull request may close these issues.

File left in HOME directory

3 participants