Giter Site home page Giter Site logo

Is it possible to output the archive file of a playlist with this syntax: "%(playlist_title)s/downloaded_archive.txt" about yt-dlp HOT 9 CLOSED

cococry avatar cococry commented on June 18, 2024
Is it possible to output the archive file of a playlist with this syntax: "%(playlist_title)s/downloaded_archive.txt"

from yt-dlp.

Comments (9)

DavidPesticcio avatar DavidPesticcio commented on June 18, 2024

Have you tried --exec [WHEN:]CMD

I haven't tried exactly as you have it, but with an RSS feed for a podcast it works, so perhaps this will work for you also;

yt-dlp -i --embed-thumbnail --add-metadata --extract-audio --audio-format mp3 --output "%(playlist_title)s/%(playlist_index)s - %(title)s.%(ext)s" --download-archive "downloaded_archive.txt" --exec "after_video:/bin/mv -v downloaded_archive.txt %(playlist_title)s/downloaded_archive.txt" <playlist>

See also for WHEN -

POSTPROCESS_WHEN = ('pre_process', 'after_filter', 'video', 'before_dl', 'post_process', 'after_move', 'after_video', 'playlist')

--exec [WHEN:]CMD               Execute a command, optionally prefixed with
                                when to execute it, separated by a ":".
                                Supported values of "WHEN" are the same as
                                that of --use-postprocessor (default:
                                after_move). Same syntax as the output
                                template can be used to pass any field as
                                arguments to the command. If no fields are
                                passed, %(filepath,_filename|)q is appended
                                to the end of the command. This option can
                                be used multiple times

from yt-dlp.

bashonly avatar bashonly commented on June 18, 2024

Or is it even possible?

Not without an external script.

Open feature request #953

from yt-dlp.

bashonly avatar bashonly commented on June 18, 2024

Have you tried --exec [WHEN:]CMD

On repeated runs, this suggestion will prevent yt-dlp from actually checking the archive before downloading, and mv would either clobber the existing archive file or fail

from yt-dlp.

DavidPesticcio avatar DavidPesticcio commented on June 18, 2024

This works (updated from %()s to %()q as per comments below from @bashonly)

Repeated runs will cause repeated entries for each ID in downloaded_archive.txt

Solved with sort -u downloaded_archive.txt -o downloaded_archive.txt

The rest is on you @cococry... πŸ˜ƒ

yt-dlp -i --embed-thumbnail --add-metadata --extract-audio --audio-format mp3 --output "%(playlist_title)s/%(playlist_index)s - %(title)s.%(ext)s" --download-archive "downloaded_archive.txt" --exec "after_video:/bin/cat downloaded_archive.txt | tee -a %(playlist_title)q/downloaded_archive.txt; rm downloaded_archive.txt" https://youtube.com/playlist?list=PL0vfts4VzfNjQOM9VClyL5R0LeuTxlAR3

from yt-dlp.

bashonly avatar bashonly commented on June 18, 2024

A word of caution: using %()s in an --exec arg is NEVER safe -- if the value contains an ' it can escape your quoting and execute arbitrary shell commands

from yt-dlp.

DavidPesticcio avatar DavidPesticcio commented on June 18, 2024

A word of caution: using %()s in an --exec arg is NEVER safe -- if the value contains an ' it can escape your quoting and execute arbitrary shell commands

Sure, but that's something that yt-dlp should manage. After all, it's yt-dlp that's expanding the values of any %()s used.

from yt-dlp.

bashonly avatar bashonly commented on June 18, 2024

Sure, but that's something that yt-dlp should manage. After all, it's yt-dlp that's expanding the values of any %()s used.

No. You are responsible for how you use --exec. And %()q should always be used, NOT %()s.

from yt-dlp.

DavidPesticcio avatar DavidPesticcio commented on June 18, 2024

Sure, but that's something that yt-dlp should manage. After all, it's yt-dlp that's expanding the values of any %()s used.

No. You are responsible for how you use --exec. And %()q should always be used, NOT %()s.

Ah, so yt-dlp does mitigate those sort of issues by escaping/quoting problematic values that it expands.

Is there a documented example and explanation of why %()q should be favoured over %()s when using --exec? - I couldn't find anything, other than a passing mention of it in the README.md. 🫀

from yt-dlp.

bashonly avatar bashonly commented on June 18, 2024

https://github.com/yt-dlp/yt-dlp#output-template

  1. More Conversions:

q = a string quoted for the terminal (flag # to split a list into different arguments)

Again, though, you are responsible for how you use --exec. It is basically just running commands with your shell. Your shell's documentation doesn't come with a warning telling you not to rm -rf /

from yt-dlp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.