cumulonix
Posts: 4
Joined: Wed Oct 03, 2012 2:24 am

Re: HOWTO: YouTube on the Raspberry Pi - sans X B-)

Wed Oct 03, 2012 9:07 pm

trinigooner wrote:Do you have youtube-dl installed? Try typing youtube-dl from the command line. If you get an error then you need to install it and put it in /usr/bin

Code: Select all

wget https://github.com/rg3/youtube-dl/raw/2012.09.27/youtube-dl
Then install it as per the instructions on page 1:

Code: Select all

sudo chmod a+x youtube-dl
sudo cp youtube-dl /usr/bin/youtube-dl
HTH
Works!
I did as you suggested (downloaded the latest youtube-dl and copied it to /usr/bin). I also recompiled yt with the '-ohdmi' option and now, I can play 1080p videos on my plasma tv. Very cool!

gawcio90
Posts: 4
Joined: Tue Sep 18, 2012 11:45 am

Re: HOWTO: YouTube on the Raspberry Pi - sans X B-)

Sun Oct 07, 2012 7:07 pm

Hi! I don't know why my yt isn't working.

Code: Select all

  File "/usr/local/bin/yt", line 9, in <module>
    load_entry_point('whitey==0.1', 'console_scripts', 'yt')()
  File "/usr/local/lib/python2.7/dist-packages/whitey-0.1-py2.7.egg/yt/__init__.                                                                    py", line 16, in main
    ui.run()
  File "/usr/local/lib/python2.7/dist-packages/whitey-0.1-py2.7.egg/yt/__init__.                                                                    py", line 56, in run
    curses.wrapper(self._curses_main)
  File "/usr/lib/python2.7/curses/wrapper.py", line 43, in wrapper
    return func(stdscr, *args, **kwds)
  File "/usr/local/lib/python2.7/dist-packages/whitey-0.1-py2.7.egg/yt/__init__.                                                                    py", line 99, in _curses_main
    self._update_screen()
  File "/usr/local/lib/python2.7/dist-packages/whitey-0.1-py2.7.egg/yt/__init__.                                                                    py", line 157, in _update_screen
    self._add_table_row(self._help, 0, 0, w-1, self._bar_attr, max_width=16, win                                                                    =self._help_bar)
  File "/usr/local/lib/python2.7/dist-packages/whitey-0.1-py2.7.egg/yt/__init__.                                                                    py", line 334, in _add_table_row
    win.addstr(y, x, truncate('%s:%s' % (k,v), min(w-x, cell_w)).encode(self._co                                                                    de), attr)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2026' in position 1                                                                    2: ordinal not in range(128)
I tried diffrent version of youtube-dl, I tried change locale en-UTF8 to us-UTF8. What can be wrong?

smiba
Posts: 9
Joined: Sat Oct 13, 2012 6:23 pm

Re: HOWTO: YouTube on the Raspberry Pi - sans X B-)

Mon Oct 15, 2012 10:19 am

I have no sound.. Its a HDMI problem

omxplayer needs to be started with "-o hdmi" but how do i do this in yt?

starous
Posts: 9
Joined: Tue Sep 18, 2012 2:48 pm

Re: HOWTO: YouTube on the Raspberry Pi - sans X B-)

Mon Oct 15, 2012 10:45 am

smiba wrote:I have no sound.. Its a HDMI problem

omxplayer needs to be started with "-o hdmi" but how do i do this in yt?
Did you read this post http://www.raspberrypi.org/phpBB3/viewt ... 972#p97972?
You need to edit your __init__.py with

Code: Select all

mplayer = subprocess.Popen(
        ['omxplayer', '-ohdmi', url.decode('UTF-8').strip()],
        stdout = subprocess.PIPE, stderr = subprocess.PIPE)
mplayer.wait()

smiba
Posts: 9
Joined: Sat Oct 13, 2012 6:23 pm

Re: HOWTO: YouTube on the Raspberry Pi - sans X B-)

Mon Oct 15, 2012 10:47 am

starous wrote:
smiba wrote:I have no sound.. Its a HDMI problem

omxplayer needs to be started with "-o hdmi" but how do i do this in yt?
Did you read this post http://www.raspberrypi.org/phpBB3/viewt ... 972#p97972?
You need to edit your __init__.py with

Code: Select all

mplayer = subprocess.Popen(
        ['omxplayer', '-ohdmi', url.decode('UTF-8').strip()],
        stdout = subprocess.PIPE, stderr = subprocess.PIPE)
mplayer.wait()
Ah. Didn't read. Thanks :D

holowey
Posts: 10
Joined: Thu Oct 18, 2012 9:16 pm

Re: HOWTO: YouTube on the Raspberry Pi - sans X B-)

Fri Oct 19, 2012 6:25 pm

starous wrote:
smiba wrote:I have no sound.. Its a HDMI problem

omxplayer needs to be started with "-o hdmi" but how do i do this in yt?
Did you read this post http://www.raspberrypi.org/phpBB3/viewt ... 972#p97972?
You need to edit your __init__.py with

Code: Select all

mplayer = subprocess.Popen(
        ['omxplayer', '-ohdmi', url.decode('UTF-8').strip()],
        stdout = subprocess.PIPE, stderr = subprocess.PIPE)
mplayer.wait()
I followed instructions given in the first post, managed to get yt running videos but no sound over hdmi whatsoever :(
tried with space '-o hdmi', tried without space '-ohdmi', same thing - no sound :(
pls help :)

simionpetrus
Posts: 1
Joined: Sat Oct 20, 2012 9:52 am

Re: HOWTO: YouTube on the Raspberry Pi - sans X B-)

Sat Oct 20, 2012 10:01 am

Code: Select all

Traceback (most recent call last):
  File "/usr/local/bin/yt", line 9, in <module>
    load_entry_point('whitey==0.1', 'console_scripts', 'yt')()
  File "/usr/local/lib/python2.7/dist-packages/whitey-0.1-py2.7.egg/yt/__init__.py", line 16, in main
    ui.run()
  File "/usr/local/lib/python2.7/dist-packages/whitey-0.1-py2.7.egg/yt/__init__.py", line 56, in run
    curses.wrapper(self._curses_main)
  File "/usr/lib/python2.7/curses/wrapper.py", line 43, in wrapper
    return func(stdscr, *args, **kwds)
  File "/usr/local/lib/python2.7/dist-packages/whitey-0.1-py2.7.egg/yt/__init__.py", line 100, in _curses_main
    self._run_pager()
  File "/usr/local/lib/python2.7/dist-packages/whitey-0.1-py2.7.egg/yt/__init__.py", line 227, in _run_pager
    self._play_video(c - ord('1'))
  File "/usr/local/lib/python2.7/dist-packages/whitey-0.1-py2.7.egg/yt/__init__.py", line 254, in _play_video
    play_url(url)
  File "/usr/local/lib/python2.7/dist-packages/whitey-0.1-py2.7.egg/yt/__init__.py", line 357, in play_url
    yt_dl = subprocess.Popen(['youtube-dl', '-g', url], stdout = subprocess.PIPE, stderr = subprocess.PIPE)
  File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

DMShropshire
Posts: 15
Joined: Thu Oct 11, 2012 3:29 am

Re: HOWTO: YouTube on the Raspberry Pi - sans X B-)

Wed Oct 24, 2012 2:02 am

Still getting this error. __init__.py edited as shown above and youtube-dl copied to /usr/bin Updated everything. It will run up until the point i try enter a number for a video

Code: Select all

[email protected] ~/whitey-0.1 $ yt
Traceback (most recent call last):
  File "/usr/local/bin/yt", line 9, in <module>
    load_entry_point('whitey==0.1', 'console_scripts', 'yt')()
  File "/usr/local/lib/python2.7/dist-packages/whitey-0.1-py2.7.egg/yt/__init__.py", line 16, in main
    ui.run()
  File "/usr/local/lib/python2.7/dist-packages/whitey-0.1-py2.7.egg/yt/__init__.py", line 56, in run
    curses.wrapper(self._curses_main)
  File "/usr/lib/python2.7/curses/wrapper.py", line 43, in wrapper
    return func(stdscr, *args, **kwds)
  File "/usr/local/lib/python2.7/dist-packages/whitey-0.1-py2.7.egg/yt/__init__.py", line 100, in _curses_main
    self._run_pager()
  File "/usr/local/lib/python2.7/dist-packages/whitey-0.1-py2.7.egg/yt/__init__.py", line 227, in _run_pager
    self._play_video(c - ord('1'))
  File "/usr/local/lib/python2.7/dist-packages/whitey-0.1-py2.7.egg/yt/__init__.py", line 254, in _play_video
    play_url(url)
  File "/usr/local/lib/python2.7/dist-packages/whitey-0.1-py2.7.egg/yt/__init__.py", line 364, in play_url
    stdout = subprocess.PIPE, stderr = subprocess.PIPE)
  File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

User avatar
jackjt8
Posts: 31
Joined: Wed Oct 17, 2012 5:16 pm

Re: HOWTO: YouTube on the Raspberry Pi - sans X B-)

Thu Oct 25, 2012 4:24 pm

And... It doesn't install YouTube-dl -_-
Beep Boop

CalumJEadie
Posts: 15
Joined: Thu Oct 18, 2012 10:51 pm
Contact: Website

Re: HOWTO: YouTube on the Raspberry Pi - sans X B-)

Sat Oct 27, 2012 1:03 pm

marktbaldridge wrote:
lenod wrote:Ok, i'm in ;)
Let's do a repo (which one, hosted where ? on a pi ? :D).
I already have a quick fix for the quality.

Yay!

It really should be hosted on a pi! :P A Pi Server. or should it be a Pi Waiter? ;)

For now, let's fork yt on github. And what do you think about putting the youtube-dl script right in our install tree? It'd save a step in the install for folks, and it's small enough...

I'd be really interested to hear if anyone did package up the adaptions to yt to make it work with omxplayer and fix any outstanding bugs?

CalumJEadie
Posts: 15
Joined: Thu Oct 18, 2012 10:51 pm
Contact: Website

Re: HOWTO: YouTube on the Raspberry Pi - sans X B-)

Sat Oct 27, 2012 2:13 pm

After a quick bit of research and experimentation with youtube-dl it seems youtube-dl is currently broken.

Has anyone else experienced similar problems in the last week?

stevepdp
Posts: 285
Joined: Fri Oct 28, 2011 7:41 am

Re: HOWTO: YouTube on the Raspberry Pi - sans X B-)

Sat Oct 27, 2012 2:26 pm

The current youtube-dl package is broken. I would recommend removing it and instead try running the updated script here.

Move it to /usr/bin/ and issue a "sudo chmod +x /usr/bin/youtube-dl" for easy access and execution :-)

CalumJEadie
Posts: 15
Joined: Thu Oct 18, 2012 10:51 pm
Contact: Website

Re: HOWTO: YouTube on the Raspberry Pi - sans X B-)

Sat Oct 27, 2012 10:25 pm

stevepdp wrote:The current youtube-dl package is broken. I would recommend removing it and instead try running the updated script here.

Move it to /usr/bin/ and issue a "sudo chmod +x /usr/bin/youtube-dl" for easy access and execution :-)
Thanks for the heads up on youtube-dl!

CalumJEadie
Posts: 15
Joined: Thu Oct 18, 2012 10:51 pm
Contact: Website

Re: HOWTO: YouTube on the Raspberry Pi - sans X B-)

Sat Oct 27, 2012 11:04 pm

Good news for viewing YouTube on the Pi!

I tracked down the developer behind http://pypi.python.org/pypi/whitey/0.1 and found that the codes online at https://github.com/rjw57/yt.

I've forked the project, added omxplayer support and expanded the documentation to explain installation, dependancies and common problems.

Check it out at https://github.com/CalumJEadie/yt.

I've been in contact with Rich and asked whether he's keen to accept pull requests and distribute the changes or whether he'd prefer for contributors to manage distribution of their own changes.

Hopefully we'll have a easily installable distribution in PyPi soon, which may be at http://pypi.python.org/pypi/whitey or a fork.

anelson55447
Posts: 1
Joined: Sat Oct 27, 2012 11:22 pm

Re: HOWTO: YouTube on the Raspberry Pi - sans X B-)

Sat Oct 27, 2012 11:38 pm

I have been able to get the python yt solution to work with both the rasbian and bodhi linux distributions. The key to getting it to work was the clue to use the internal update for youtube-dl after you initially install it:

sudo youtube-dl -U

Once I did this the yt/youtube-dl/omxplayer combo worked perfectly. Thanks to the other contributors for this problem fix.

nfx
Posts: 3
Joined: Wed May 30, 2012 6:55 am

Re: HOWTO: YouTube on the Raspberry Pi - sans X B-)

Sun Oct 28, 2012 6:20 pm

running latest youtube-dl on raspbian I get error:

Code: Select all

Traceback (most recent call last):
  File "/usr/local/bin/yt", line 9, in <module>
    load_entry_point('whitey==0.1', 'console_scripts', 'yt')()
  File "/usr/local/lib/python2.7/dist-packages/whitey-0.1-py2.7.egg/yt/__init__.py", line 16, in main
    ui.run()
  File "/usr/local/lib/python2.7/dist-packages/whitey-0.1-py2.7.egg/yt/__init__.py", line 56, in run
    curses.wrapper(self._curses_main)
  File "/usr/lib/python2.7/curses/wrapper.py", line 43, in wrapper
    return func(stdscr, *args, **kwds)
  File "/usr/local/lib/python2.7/dist-packages/whitey-0.1-py2.7.egg/yt/__init__.py", line 100, in _curses_main
    self._run_pager()
  File "/usr/local/lib/python2.7/dist-packages/whitey-0.1-py2.7.egg/yt/__init__.py", line 227, in _run_pager
    self._play_video(c - ord('1'))
  File "/usr/local/lib/python2.7/dist-packages/whitey-0.1-py2.7.egg/yt/__init__.py", line 254, in _play_video
    play_url(url)
  File "/usr/local/lib/python2.7/dist-packages/whitey-0.1-py2.7.egg/yt/__init__.py", line 361, in play_url
    raise RuntimeError('Error getting URL.')
RuntimeError: Error getting URL.

CalumJEadie
Posts: 15
Joined: Thu Oct 18, 2012 10:51 pm
Contact: Website

Re: HOWTO: YouTube on the Raspberry Pi - sans X B-)

Mon Oct 29, 2012 9:19 am

Rich has merged omxplayer support and the extended documentation into his yt repo and will be distributing the latest version of yt on PyPi soon!

Check out https://github.com/rjw57/yt for documentation on using yt with Omxplayer, installation and dependancy instructions, and solutions to common problems.

CalumJEadie
Posts: 15
Joined: Thu Oct 18, 2012 10:51 pm
Contact: Website

Re: HOWTO: YouTube on the Raspberry Pi - sans X B-)

Mon Oct 29, 2012 5:57 pm

Rich has released the latest version of yt, with Omxplayer support, to PyPi.

Check out the source code at https://github.com/rjw57/yt and the PyPi page at http://pypi.python.org/pypi/whitey/0.2.

Get it up and running on your machine with:

Code: Select all

sudo apt-get install youtube-dl # Installs dependancies.
sudo youtube-dl -U # Makes sure latest version is used.
sudo apt-get install python-setuptools
sudo easy_install whitey # Install yt - different name used to avoid conflict with existing project.
yt --player omxplayer # Specify Omxplayer rather than default MPlayer.

jose1711_
Posts: 58
Joined: Sat Jul 21, 2012 10:03 am

Re: HOWTO: YouTube on the Raspberry Pi - sans X B-)

Tue Oct 30, 2012 5:52 pm

does skipping with arrow keys work for anyone? jose

bbond007
Posts: 73
Joined: Sun Nov 04, 2012 6:10 pm

Re: HOWTO: YouTube on the Raspberry Pi - sans X B-)

Sat Nov 10, 2012 5:18 am

First off, let me say this is a fantastic program and I really like it!

The problem I had was that my steam-powered DSL connection was not fast enough with the default settings. I also have been using my RPi connected to a 3G phone, so I wanted to tune it up for that.

Anyway, I altered the __init__.py program to allow for some more options.

--output [hdmi,local] --quality [low,medium,high]

also I assigned "z" as a hotkey to switch quality and reflect that setting on the help bar.

I tried to match the style and intent of the original program, but this is the first time I have tried to use the language.

Anyway, if anyone wants take a look, just let me know the best way to pass it along.

thanks

Hej-san
Posts: 2
Joined: Sun Nov 11, 2012 1:35 pm

Re: HOWTO: YouTube on the Raspberry Pi - sans X B-)

Sun Nov 11, 2012 1:49 pm

I don't get it. It isn't working!!! Please help me, I can't install omxplayer.

User avatar
michele.x
Posts: 72
Joined: Sat Sep 22, 2012 8:15 pm

Re: HOWTO: YouTube on the Raspberry Pi - sans X B-)

Sun Nov 11, 2012 5:31 pm

Really nice program! Anyway I made a small patch that make three useful things:

- mplayer is called with fbdev2 output mode, that seems to work sufficentrly on the pi
- the video quality is fixed, intead of the max quality --- it's a kludge, but work for me an my slow dsl.
- whe a video is played the screen is cleared, so when in a 4:3 tv a 16:9 video is played the letterbox is blackened, and doesn't contain the menus.

Code: Select all

--- __init__.py	2012-10-29 11:09:18.000000000 +0100
+++ /usr/local/lib/python2.7/dist-packages/whitey-0.2-py2.7.egg/yt/__init__.py	2012-11-11 17:47:27.819060266 +0100
@@ -20,7 +20,7 @@
 
     # Allow the user to specify whether to use mplayer or omxplayer for playing videos.
     parser = argparse.ArgumentParser(prog='yt',formatter_class=argparse.ArgumentDefaultsHelpFormatter)
-    parser.add_argument("--player",default=MPLAYER_MODE,choices=[MPLAYER_MODE,OMXPLAYER_MODE],help="specifies what program to use to play videos")
+    parser.add_argument("--player",default=OMXPLAYER_MODE,choices=[MPLAYER_MODE,OMXPLAYER_MODE],help="specifies what program to use to play videos")
    
     args = parser.parse_args(sys.argv[1:])
 
@@ -368,22 +368,33 @@
         return '%.1fk' % (n/1000.0,)
     return '%.1fM' % (n//1000000.0,)
 
+def fillwin(w, c):
+    y, x = w.getmaxyx()
+    s = c * (x - 1)
+    for l in range(y):
+        w.addstr(l, 0, s)
+
 def play_url(url,player):
-    yt_dl = subprocess.Popen(['youtube-dl', '-g', url], stdout = subprocess.PIPE, stderr = subprocess.PIPE)
+    yt_dl = subprocess.Popen(['youtube-dl','--max-quality','35', '-g', url], stdout = subprocess.PIPE, stderr = subprocess.PIPE)
     (url, err) = yt_dl.communicate()
     if yt_dl.returncode != 0:
         sys.stderr.write(err)
-        raise RuntimeError('Error getting URL.')
+        raise RuntimeError(err)
 
     assert player in [MPLAYER_MODE,OMXPLAYER_MODE]
+    wind = curses.newwin(0,0)
+    wind.erase()
+    # fillwin(wind,'*')
+    wind.touchwin()
+    wind.refresh()
     if player == MPLAYER_MODE:
         play_url_mplayer(url)
     else:
         play_url_omxplayer(url)
-    
+    del wind
 def play_url_mplayer(url):
     player = subprocess.Popen(
-            ['mplayer', '-quiet', '-fs', '--', url.decode('UTF-8').strip()],
+            ['mplayer', '-vo','fbdev2','-quiet', '-fs', '--', url.decode('UTF-8').strip()],
             stdout = subprocess.PIPE, stderr = subprocess.PIPE)
     player.wait()
         


CalumJEadie
Posts: 15
Joined: Thu Oct 18, 2012 10:51 pm
Contact: Website

Re: HOWTO: YouTube on the Raspberry Pi - sans X B-)

Sun Nov 18, 2012 7:19 pm

Great to see patches being posted for yt!

I'm afraid I'm not able to get involved with development at the moment personally however I recommend you contribute your patches as pull requests to https://github.com/rjw57/yt.

If there's a feature you'd like but aren't sure how to add it would be useful to have that as a feature request in the issue tracker https://github.com/rjw57/yt/issues.

User avatar
billybangleballs
Posts: 128
Joined: Fri May 18, 2012 11:28 pm

Re: HOWTO: YouTube on the Raspberry Pi - sans X B-)

Wed Nov 21, 2012 10:21 am

It works good, only there is no sound.
Omxplayer normally produces a *clunk* through the speakers when it is started, but it doesn't when called by yt.
I assume it is trying to send the audio via hdmi but I want it at the 3.5mm socket.
Anyone know how to fix this?
Grumpy old man.
Ex-G0KAP - I'd rather be doing it than talking about it.
"When found, make a note of." - Captain Cuttle

User avatar
billybangleballs
Posts: 128
Joined: Fri May 18, 2012 11:28 pm

Re: HOWTO: YouTube on the Raspberry Pi - sans X B-)

Wed Nov 21, 2012 11:17 am

I figured it out, I edited the file /usr/local/lib/python2.7/dist-packages/whitey-0.2-py2.7.egg/yt/__init__.py
and changed the line

Code: Select all

['omxplayer', '-ohdmi', url.decode('UTF-8').strip()],
 to 
['omxplayer', url.decode('UTF-8').strip()],
Job sorted.
Grumpy old man.
Ex-G0KAP - I'd rather be doing it than talking about it.
"When found, make a note of." - Captain Cuttle

Return to “Media centres”

Who is online

Users browsing this forum: No registered users and 3 guests