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

Forward the download location to another (grep) program? #26515

Closed
Wogol opened this issue Sep 3, 2020 · 7 comments
Closed

Forward the download location to another (grep) program? #26515

Wogol opened this issue Sep 3, 2020 · 7 comments
Labels

Comments

@Wogol
Copy link

@Wogol Wogol commented Sep 3, 2020

Checklist

  • I'm asking a question
  • I've looked through the README and FAQ for similar questions
  • I've searched the bugtracker for similar questions including closed ones

Question

WRITE QUESTION HERE

Trying to make a easy to use script to download YouTube videos easy and also create a info file with Title, Channel, channel URL, upload date, tags, url to video and also description. I found that the information is in the JSON file that youtube-dl download. What Im struggling with is how to get the folder location information from youtube-dl to grep that then can access JSON file and copy that information to a dedicated text file.

$folder'/%(title)s/%(title)s - (%(id)s) - %(uploader)s - %(upload_date)s.%(ext)s'

$folder is a location the user choose earlier in the script. I have added ID, uploader and upload date to the files because that is the only way I know to get that information saved in a "easy" way to access it.

Is there a way to do this?

More information about the script here https://stackoverflow.com/questions/63336809/youtube-dl-download-script-debug

@Wogol Wogol added the question label Sep 3, 2020
@reallyuniquename
Copy link

@reallyuniquename reallyuniquename commented Sep 3, 2020

Just get it from the youtube-dl output?

@Wogol
Copy link
Author

@Wogol Wogol commented Sep 3, 2020

Can you explain more?

I have read youtube-dl manual and dont find anything about how to get it there.

@reallyuniquename
Copy link

@reallyuniquename reallyuniquename commented Sep 3, 2020

You want to get the value of $folder'/%(title)s/%(title)s - (%(id)s) - %(uploader)s - %(upload_date)s.%(ext)s' after youtube-dl finishes the job, is that correct?

@Wogol
Copy link
Author

@Wogol Wogol commented Sep 3, 2020

Yes, and get that to grep. Specially the json file. As said before, I already have $folder so only youtube-dl value of '/%(title)s/%(title)s - (%(id)s) - %(uploader)s - %(upload_date)s.%(ext)s' is needed. This so grep knows where the json file is and also where to write the text file.

@reallyuniquename
Copy link

@reallyuniquename reallyuniquename commented Sep 3, 2020

Youtube-dl prints complete name of a file

[download] Destination: Video-12345-abc-2020.mp4

You could extract that by grepping its output.

You could also use --get-filename option that requires running youtube-dl once again but it doesn't download anything, or you could use --exec that passes filename to whatever command you specify.

@Wogol
Copy link
Author

@Wogol Wogol commented Sep 4, 2020

Thanks for your help. Have completely missed that part that youtube-dl prints the name and path of the video file.

Have just got information about a program called xidel and with that no need to download description or json file. I do not know how to do this but some how get the path and filename of from youtube-dl, replace the extension (mp4) with txt and dump the xidel output there to that text file. I do not want to run youtube-dl two times.

youtube-dl output

[download] Destination: /location/of/video/Video-12345-abc-2020.mp4

txt file for xidel to dump the output from the script below.

/location/of/video/Video-12345-abc-2020.txt

xidel -s https://www.youtube.com/watch?v=dQw4w9WgXcQ -e '
  let $json:=json(
        //script/extract(.,"ytplayer.config = (.+?\});",1)[.]
      )/args,
      $a:=json($json/player_response)/videoDetails,
      $b:=json($json/player_response)/microformat
  return (
    "- TITLE -",
    $a/title,"",
    "- CHANNEL -",
    $a/author,"",
    "- CHANNEL URL -",
    $b//ownerProfileUrl,"",
    "- UPLOAD DATE -",
    $b//publishDate,"",
    "- URL -",
    $json/loaderUrl,"",
    "- TAGS -",
    $a/keywords,"",
    "- DESCRIPTION -",
    $a/shortDescription
  )
' --printed-json-format=compact
@reallyuniquename
Copy link

@reallyuniquename reallyuniquename commented Sep 4, 2020

At this point it's not a youtube-dl issue, you need to learn bash basics.

@dstftw dstftw closed this Sep 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.