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

Option to combine -o and -g #9239

Open
IamCarbonMan opened this issue Apr 18, 2016 · 5 comments
Open

Option to combine -o and -g #9239

IamCarbonMan opened this issue Apr 18, 2016 · 5 comments
Labels

Comments

@IamCarbonMan
Copy link

@IamCarbonMan IamCarbonMan commented Apr 18, 2016

  • I've verified and I assure that I'm running youtube-dl 2016.04.13
  • At least skimmed through README and most notably FAQ and BUGS sections
  • Searched the bugtracker for similar issues including closed ones

What is the purpose of your issue?

  • Bug report (encountered problems with youtube-dl)
  • Site support request (request for adding support for a new site)
  • Feature request (request for a new functionality)
  • Question
  • Other

Description of your issue, suggested solution and other information

I use Kodi Media Center for all my entertainment and media management. This program is capable of playing streaming video in many formats from an url written in a .strm file. I would like to use youtube-dl to output a playlist of music videos in a specific format (say, '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' which will put playlist files into a common folder, but instead of actually downloading the video, just echo the url (as given by the -g option) into the file. I have actually accomplished this using a bash script which parses the output of youtube-dl --get-filename --get-url but it is a very hacky solution. Any chance this could become a feature?

EDIT: To give an example, I would like to be able to run youtube-dl -f best -g -o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' https://www.youtube.com/playlist?list=PLY5f8vtstsfjedMi6VHRAeFV85Xc_VoKG and see afterwards a subdirectory in the working dir of youtube-dl, which is named by the title of the playlist (in this case, NateWantsToBattle Songs) and in that subfolder would be a number of files named according to their order in the playlist and title (in this case, one would be named "NateWantsToBattle Songs/01 - twenty one pilots - Stressed Out [NateWantsToBattle feat. ShueTube].mp4") and each file would contain only the plain-text url of the video as shown by -g (the example above would contain the url string shown here).

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Apr 20, 2016

Could you give some concrete video links and your expected output?

@kn00tcn
Copy link

@kn00tcn kn00tcn commented Apr 20, 2016

great idea & it does have links... does github not list the time that OP's post was edited?

@Hrxn
Copy link

@Hrxn Hrxn commented Apr 21, 2016

Well, no. Edits don't activate notifications and alerts either..

@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Apr 21, 2016

I think this can be easily achieved with a script:

#!/bin/sh
youtube-dl -j "$@" | python -c '
import sys
import json
import os
for line in sys.stdin.readlines():
    info = json.loads(line)
    fname = info["_filename"]
    dir = os.path.dirname(fname)
    if dir and not os.path.exists(dir):
        os.makedirs(dir)
    with open(fname, "wt") as f:
        f.write(info["url"])
'

I don't find it hacky, although others may disagree.

@IamCarbonMan
Copy link
Author

@IamCarbonMan IamCarbonMan commented Apr 25, 2016

I am now using this script and it does exactly what I wanted. I forked the repository and was gonna make a PR with the required changes, but I don't know how to properly do this in the context of youtube-dl's workflow (it looks to me like a file is created in the same function as downloading something to it, and while I suppose I could probably make it download a pastebin of the url somehow, it seems, well, too hacky. How could this be integrated into the application in a more elegant way?

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
5 participants
You can’t perform that action at this time.