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

youtube-dl youtube.com/user/<ytuser> -j | grep -m 1 -Po '(?<="uploader_id": ")[^"]*' fails #9221

Closed
sapphonie opened this issue Apr 16, 2016 · 2 comments

Comments

@sapphonie
Copy link

@sapphonie sapphonie commented Apr 16, 2016

Please follow the guide below

  • You will be asked some questions and requested to provide some information, please read them carefully and answer honestly
  • Put an x into all the boxes [ ] relevant to your issue (like that [x])
  • Use Preview tab to see how your issue will actually look like

Make sure you are using the latest version: run youtube-dl --version and ensure your version is 2016.04.13. If it's not read this FAQ entry and update. Issues with outdated version will be rejected.

  • I've verified and I assure that I'm running youtube-dl 2016.04.13

Before submitting an issue make sure you have:

  • 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

The following sections concretize particular purposed issues, you can erase any section (the contents between triple ---) not applicable to your issue


If the purpose of this issue is a bug report, site support request or you are not completely sure provide the full verbose output as follows:

Add -v flag to your command line you run youtube-dl with, copy the whole output and insert it here. It should look similar to one below (replace it with your log inserted between triple ```):

bash shell, btw

$ youtube-dl youtube.com/user/supdawg444 -v -j | grep -m 1 -Po '(?<="uploader_id": ")[^"]*'
[debug] System config: []
[debug] User config: []
[debug] Command-line args: [u'youtube.com/user/supdawg444', u'-v', u'-j']
[debug] Encodings: locale UTF-8, fs UTF-8, out None, pref UTF-8
[debug] youtube-dl version 2016.04.13
[debug] Python version 2.7.10 - Linux-4.2.0-35-generic-x86_64-with-Ubuntu-15.10-wily
[debug] exe versions: avconv 2.7.6-0ubuntu0.15.10.1, avprobe 2.7.6-0ubuntu0.15.10.1, ffmpeg 2.7.6-0ubuntu0.15.10.1, ffprobe 2.7.6-0ubuntu0.15.10.1, rtmpdump 2.4
[debug] Proxy map: {}
WARNING: The url doesn't specify the protocol, trying with http
supdawg444
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/bin/youtube-dl/__main__.py", line 19, in <module>
  File "/usr/local/bin/youtube-dl/youtube_dl/__init__.py", line 419, in main
  File "/usr/local/bin/youtube-dl/youtube_dl/__init__.py", line 409, in _real_main
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1730, in download
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 682, in extract_info
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 734, in process_ie_result
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 682, in extract_info
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 734, in process_ie_result
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 682, in extract_info
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 842, in process_ie_result
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 734, in process_ie_result
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 682, in extract_info
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 727, in process_ie_result
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1376, in process_video_result
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1479, in process_info
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 442, in to_stdout
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 431, in _write_string
  File "/usr/local/bin/youtube-dl/youtube_dl/utils.py", line 1167, in write_string
IOError: [Errno 32] Broken pipe
...
<end of log>

Description of your issue, suggested solution and other information

No idea. Seems like running grep on some json output fails, for some reason. I'm just trying to come up with a regex expression to grep on the JSON output.

So far I can do

youtube-dl youtube.com/user/<user> -v -j | grep -Po '(?<="uploader_id": ")[^"]* 

and get the uploader_id, but it outputs it every time it finds a new video, so I end up with the uploader_id duplicated for however many videos the youtube channel has.

That's what the -m 1 in the grep command was for, but it failed. No idea why.

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Apr 17, 2016

You should not grep on JSON use jq instead.
-m 1 fails since grep stops reading from stdin after the first match while youtube-dl continues to write into pipe on each new video. Limit processing to just one video if you don't need to process all --playlist-end 1.

@dstftw dstftw closed this Apr 17, 2016
@sapphonie
Copy link
Author

@sapphonie sapphonie commented Apr 17, 2016

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