-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
struggling to find the right stage for --print-to-file
comments
#6939
Comments
As I already pointed out in another issue, the infodict of For others, show verbose log. I shouldn't have to try it myself or make guesses to answer! |
This comment was marked as resolved.
This comment was marked as resolved.
The file is being written, just not where you expected.
I believe I mentioned in a previous issue (when we discussed aliases?) that you cannot use variables like this. No?1 Fields are sanitized when used in filenames. You are going about this the totally wrong way as I have been repeatedly saying. The way to avoid duplicating code is not to try and perform magic with When you asked how to extract download dir, I assumed you just want it to be used for --exec etc, not to by passed into yet another Footnotes
|
This comment was marked as off-topic.
This comment was marked as off-topic.
I'd need to tell the script where the
For example: How can I achieve that? |
Why ??
Isn't this very much alike ?
Why? As far as I can see, all my problems would be solved if 3 variables were available at all stages and for all parameters (not just for print) as requested in #6931:
This would really be a godsend. I think this is a decent request.
Ok, so I guess I cannot use |
Because
It's not for playlists, but
No, you don't. You are the one telling yt-dlp what template to use in the first place. See this example batch script: set "download_dir=C:\%%(id)s"
yt-dlp -o "%download_dir%\%%(title)s" --print-to-file "%%(comments|)j" "%download_dir%\comments.json" |
I am not sure I understand. I cannot call yt-dlp with
I won't ever be able to recreate all of this in an external shell script (and even if I were, it would likely fail due to codepage hell).
I don't think this is the problem, because
|
@pukkandan : I don't understand why you don't want to give us the 3 variables referenced above. This would solve all problems and outstanding issues. If this is tricky to code, I understand.
You already succeeded in Populate |
The var is not set to the actual dir, but the template. See how my example uses
No,
It wouldn't, because of above |
I am absolutely certain it would, because:
This works! ✔️ For example, I could solve my last remaining problem (prevent overwriting/appending preexisting metadata files) as follows if only the fields were available at
|
The problem is when you pass it as a filename to I'm sorry, I don't know how to explain it any better. If you are sure it works, feel free to try implementing it and prove me wrong. Here is a POC implementation for adding the field: diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py
index 8ee42b86a..b87f7b488 100644
--- a/yt_dlp/YoutubeDL.py
+++ b/yt_dlp/YoutubeDL.py
@@ -1122,6 +1122,9 @@ def prepare_outtmpl(self, outtmpl, info_dict, sanitize=False):
"""
info_dict.setdefault('epoch', int(time.time())) # keep epoch consistent once set
+ if 'download_dir' not in info_dict:
+ info_dict['download_dir'] = None # Prevent recurssion
+ info_dict['download_dir'] = os.path.dirname(self.prepare_filename(info_dict))
info_dict = self._copy_infodict(info_dict)
info_dict['duration_string'] = ( # %(duration>%H-%M-%S)s is wrong if duration > 24hrs |
Ok, so you agree that it would solve my problem (which uses
Above, I have already provided proof that it works (for
I'll play around to see if I can find a solution for that. But even if this ultimately fails and But on the other hand, if
What are you suggesting I should do? I haven't learned yet how to compile python code. |
I believe I have already given explanations and alternate solutions for these to the best of my ability. I am not going to try and write them again. The tldr is:
|
Honestly, this leaves me heartbroken. For days on end I've been struggling to make things work and now you have even presented the solution in your code above but you don't want to add that code? Was that just to tease me?
Isn't this a strong usecase given that it would solve a lot of issues ?
I have yet to determine that, but it definitely WILL solve all problems that depend on
@pukkandan : I think you still partially misunderstand the problem: The user cannot I already explained this above in:
As I already said in collapsed comment above @bashonly has solved 50% (the
I explained in #6939 (comment) why I don't think it can be solved via an external script. |
I don't know what else to say, except ... just ... please 🙏 🛐 |
It has many subtle bugs and since was just meant to be a POC so that you could see for yourself why adding a field won't actually solve your problems. But since you don't seem to know how to run patch yt-dlp from source, that ended up a pointless attempt.
My point is that IT WONT! You have yet to show any use case which can't be done easily without this. I don't see any You might want to explain what you are actually trying to accomplish. Is it just to write comments and delete it when empty? If so, you are extremely overcomplicating this. I bet your requirement will end up being easier for me to write the script for you than to continue this discussion.
and I replied:
You should just change |
--print-to-file
comments
I will try figuring out your scripting suggestion, but I am afraid this will open a new can of worms.
Ok, then thank you for still trying to help me out. I have come a long way (thanks to your help) during the last weeks, but
3. solved
|
DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE
Checklist
Please make sure the question is worded well enough to be understood
Could you please tell me what I am doing wrong? I'm trying different stages for
--print-to-file
but none of them work:after_video
This
✔️ successfully creates a file with filename
84 comments.json
with 84 comments but❌ in the wrong place:
C:\downloads\~~\!nfo
instead ofC:\downloads\2012-10-02 youtube-dl test video\!nfo
log
after_move
This
❌ creates no comments.json file
Why ??
log
post_process
This
❌ creates an empty comments.json file
❌ in the wrong place:
c:\downloads\c:⧹downloads⧹2012-10-02 youtube-dl test video\
instead ofC:\downloads\2012-10-02 youtube-dl test video\!nfo
(note
:
vs:
)log
Provide verbose output that clearly demonstrates the problem
yt-dlp -vU <your command line>
)'verbose': True
toYoutubeDL
params instead[debug] Command-line config
) and insert it belowComplete Verbose Output
see above
The text was updated successfully, but these errors were encountered: