pyTivo Discussion Forum Forum Index pyTivo Discussion Forum
Answers and the development of pyTivo a TiVo transcoding server
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

YouTube Browser, sneak preview

 
Post new topic   Reply to topic    pyTivo Discussion Forum Forum Index -> Miscellaneous
 View previous topic :: View next topic  
Author Message
wmcbrine



Joined: 04 Jan 2008
Posts: 444

PostPosted: Fri Mar 07, 2008 8:15 am    Post subject: YouTube Browser, sneak preview Reply with quote

Here's a little something to help you grab YouTube vids onto your TiVo. It's based on a stripped-down pyTivo, plus a simple YouTube library I wrote back in November. That's how long I've been planning this... I finally got around to it in the last couple of days. It's nowhere near finished -- I plan to add an HME front end so you can select videos from the TiVo, follow "related" links, etc. But I don't know how long that will take, and heck, it's faster to type search terms on your computer anyway. Smile

Right now, it only works by doing a search. You can specify the search terms on the command line, or wait for the prompt. When you want to do a new search, you have to restart it.

It needs the Cheetah library (you can copy it from pyTivo if necessary), and ffmpeg. The only thing you should need to configure (in yserver.conf) is the location of ffmpeg, although you can also change the port, beacon and guid if necessary (same style as pyTivo). The default port is 9043 instead of 9032, and the default guid is "YouTube-Browser-0.01", so you can run it alongside pyTivo if you like.

Start: "./yserver.py" or "python yserver.py".

Since this is a very preliminary version, I'm not looking for bug reports, and it's basically unsupported. Please don't post it to TCF yet.



yb-0.01.zip
 Description:

Download
 Filename:  yb-0.01.zip
 Filesize:  7.62 KB
 Downloaded:  60 Time(s)


_________________
My pyTivo fork
Back to top
View user's profile Send private message
scarymike23



Joined: 08 Jan 2008
Posts: 5

PostPosted: Thu Mar 13, 2008 7:46 am    Post subject: Reply with quote

Help a newb out?

I installed these files into c:\Program Files\youtubetivo

I set up the yserver.conf with the correct path to ffmpeg. I coppied the Cheetah folder from pytivo to this folder as well.

I just can't seem to run it.

i went into my python dir: c:\Python25 via cmd (i'm on winxp)
and typed

python.exe "c:\Program Files\youtubetivo\yserver.py"
and I get:

Traceback (most recent call last):
File "c:\Program Files\youtubetivo\yserver.py", line 15, in <module>
import youtube
File "C:\Program Files\youtubetivo\youtube.py", line 4, in <module>
from xml.utils import iso8601
ImportError: No module named utils


Lil help?

_________________
-SM
Back to top
View user's profile Send private message
wmcbrine



Joined: 04 Jan 2008
Posts: 444

PostPosted: Thu Mar 13, 2008 11:00 am    Post subject: Reply with quote

Hmm. It appears that I was relying on something that's only in PyXML -- parts of it are in the Python standard library now, but that part's not.

You could install PyXML, or wait to see if I can replace this with something that is in the standard library.

Or, if you don't care about the date, take out that line, and replace these lines:
Code:
        if date_tag:
            self.date = iso8601.parse(text(date_tag))
        else:
            self.date = -1

with:
Code:
        self.date = -1

See, this is why it's unsupported. I would've noticed this if I'd tested it on more than one machine.

_________________
My pyTivo fork
Back to top
View user's profile Send private message
sicklybutsexy



Joined: 05 Mar 2008
Posts: 73
Location: chicago

PostPosted: Thu Mar 13, 2008 6:34 pm    Post subject: Reply with quote

you also have to take out line 4 and then it works great on windows xp without the date of course. thanks, great program.
Back to top
View user's profile Send private message
sicklybutsexy



Joined: 05 Mar 2008
Posts: 73
Location: chicago

PostPosted: Thu Mar 13, 2008 6:37 pm    Post subject: Reply with quote

wait, I spoke too soon. It gets the metadata but when I go to transfer the video nothing comes over to the tivo. any ideas?
Back to top
View user's profile Send private message
sicklybutsexy



Joined: 05 Mar 2008
Posts: 73
Location: chicago

PostPosted: Thu Mar 13, 2008 6:41 pm    Post subject: Reply with quote

Here's what I get...




192.168.1.103 - - [13/Mar/2008 21:39:26] "GET /YouTube/d_vv12NSSZ4 HTTP/1.1" 200
-
----------------------------------------
Exception happened during processing of request from ('192.168.1.103', 1217)
Traceback (most recent call last):
File "C:\Python25\lib\SocketServer.py", line 464, in process_request_thread
self.finish_request(request, client_address)
File "C:\Python25\lib\SocketServer.py", line 254, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Python25\lib\SocketServer.py", line 522, in __init__
self.handle()
File "C:\Python25\lib\BaseHTTPServer.py", line 316, in handle
self.handle_one_request()
File "C:\Python25\lib\BaseHTTPServer.py", line 310, in handle_one_request
method()
File "C:\Documents and Settings\jay\My Documents\yb-0[1].01\yserver.py", line
94, in do_GET
plugin.send_file(self, container, name)
File "C:\Documents and Settings\jay\My Documents\yb-0[1].01\video.py", line 16
6, in send_file
output_video(source, handler.wfile)
File "C:\Documents and Settings\jay\My Documents\yb-0[1].01\video.py", line 42
, in output_video
ffmpeg = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=inFile)
File "C:\Python25\lib\subprocess.py", line 586, in __init__
errread, errwrite) = self._get_handles(stdin, stdout, stderr)
File "C:\Python25\lib\subprocess.py", line 698, in _get_handles
p2cread = msvcrt.get_osfhandle(stdin.fileno())
IOError: [Errno 9] Bad file descriptor
----------------------------------------
Back to top
View user's profile Send private message
sicklybutsexy



Joined: 05 Mar 2008
Posts: 73
Location: chicago

PostPosted: Thu Mar 13, 2008 6:47 pm    Post subject: Reply with quote

this might help. can't figure it out. It does everything right up to actually transferring the video over.



Exception happened during processing of request from ('192.168.1.103', 1233)
Traceback (most recent call last):
File "C:\Python25\lib\SocketServer.py", line 464, in process_request_thread
self.finish_request(request, client_address)
File "C:\Python25\lib\SocketServer.py", line 254, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Python25\lib\SocketServer.py", line 522, in __init__
self.handle()
File "C:\Python25\lib\BaseHTTPServer.py", line 316, in handle
self.handle_one_request()
File "C:\Python25\lib\BaseHTTPServer.py", line 310, in handle_one_request
method()
File "C:\Documents and Settings\jay\My Documents\yb-0[1].01\yserver.py", line
94, in do_GET
plugin.send_file(self, container, name)
File "C:\Documents and Settings\jay\My Documents\yb-0[1].01\video.py", line 16
6, in send_file
output_video(source, handler.wfile)
File "C:\Documents and Settings\jay\My Documents\yb-0[1].01\video.py", line 42
, in output_video
ffmpeg = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=inFile)
File "C:\Python25\lib\subprocess.py", line 586, in __init__
errread, errwrite) = self._get_handles(stdin, stdout, stderr)
File "C:\Python25\lib\subprocess.py", line 698, in _get_handles
p2cread = msvcrt.get_osfhandle(stdin.fileno())
IOError: [Errno 9] Bad file descriptor
----------------------------------------
192.168.1.103 - - [13/Mar/2008 21:44:43] "GET /TiVoConnect?Command=QueryFormats&
SourceFormat=video%2Fx-tivo-mpeg HTTP/1.1" 200 -
192.168.1.103 - - [13/Mar/2008 21:44:43] "GET /TiVoConnect?Command=QueryContaine
r&Container=YouTube&SortOrder=!CaptureDate&ItemCount=8&AnchorItem=%2FYouTube%2FE
gt-nwZ6Ym8&AnchorOffset=-1&Filter=x-tivo-container%2Ftivo-videos,x-tivo-containe
r%2Ffolder,video%2Fx-tivo-mpeg,video%2F* HTTP/1.1" 200 -
192.168.1.103 - - [13/Mar/2008 21:44:50] "GET /TiVoConnect?Command=QueryContaine
r&Container=%2F HTTP/1.0" 200 -
192.168.1.103 - - [13/Mar/2008 21:45:03] "GET /TiVoConnect?Command=QueryContaine
r&Container=%2F HTTP/1.0" 200 -
Back to top
View user's profile Send private message
wmcbrine



Joined: 04 Jan 2008
Posts: 444

PostPosted: Thu Mar 13, 2008 8:01 pm    Post subject: Reply with quote

Ah, Windows, the gift that keeps on giving. Razz Apparently it doesn't like piping input from urlopen().

I'll see what I can do... in the meantime, I can only suggest trying it on a sane OS (Linux, Mac OS X, etc.).

_________________
My pyTivo fork
Back to top
View user's profile Send private message
scarymike23



Joined: 08 Jan 2008
Posts: 5

PostPosted: Sun Mar 23, 2008 5:54 pm    Post subject: Reply with quote

wmcbrine wrote:
Ah, Windows, the gift that keeps on giving. Razz Apparently it doesn't like piping input from urlopen().

I'll see what I can do... in the meantime, I can only suggest trying it on a sane OS (Linux, Mac OS X, etc.).


Any luck getting this to work with Windows?

_________________
-SM
Back to top
View user's profile Send private message
wmcbrine



Joined: 04 Jan 2008
Posts: 444

PostPosted: Sun Mar 23, 2008 8:45 pm    Post subject: Reply with quote

Not yet. I posted about it on the comp.lang.python newsgroup, which I've previously found extremely helpful, and got one reply, saying "you're stuck".

I'm not giving up, but it might require something ugly...

_________________
My pyTivo fork
Back to top
View user's profile Send private message
real_armooo
pyTivo Creator


Joined: 23 Mar 2008
Posts: 42

PostPosted: Wed Mar 26, 2008 8:17 pm    Post subject: Reply with quote

The problem is that on windows tcp sockets are not file descriptors. This is why pytivo is using shutil.copyfileobj(f, outFile) to copy the file from stdout to the socket. You will need to watch out for deadlock problems when you feed data in to ffmpeg faster that it is processing it. Even starting a new thread to feed stdin may not work because of the GIL.
Back to top
View user's profile Send private message
jlc4



Joined: 19 Feb 2008
Posts: 16

PostPosted: Sat Apr 05, 2008 9:21 am    Post subject: Reply with quote

real_armooo wrote:
The problem is that on windows tcp sockets are not file descriptors. This is why pytivo is using shutil.copyfileobj(f, outFile) to copy the file from stdout to the socket. You will need to watch out for deadlock problems when you feed data in to ffmpeg faster that it is processing it. Even starting a new thread to feed stdin may not work because of the GIL.


Actually, if I remember correctly, sockets are file descriptors (handles in window-speak), but unless you jump through some silly windows hoops the socket cannot be inherited by the child process. Can you access the microsoft win32 API's from python?
Back to top
View user's profile Send private message
xkahn



Joined: 09 Apr 2008
Posts: 2

PostPosted: Wed Apr 09, 2008 8:28 pm    Post subject: Another method to download youtube Reply with quote

So I worked on this problem for a while and decided to hook up my RSS feed reader to pytivo with a little python glue. I threw the attached script together and ... it worked!

If you want to try it, you'll need:

I've only tested this on Linux, and it will likely only work there.

Edit the script, replacing "/home/xkahn/Videos/youtube/" with the path you set pyTivo to serve videos from. And replace "/home/xkahn/bin/youtube-dl.py" with the path to youtube-dl.py

Then find an interesting youtube RSS feed. Like: http://youtube.com/rss/global/top_favorites.rss and subscribe to it with liferea. For the conversion filter, point to the python script.

Soon, you'll have lots of youtube videos!

Uhh... So it isn't easy to use yet. Embarassed It is only a proof of concept.

Bugs:

  • Too hard to set up (no config file)
  • No real feedback
  • Doesn't erase videos no longer in the feed
  • A little heavy to rely on liferea
  • Downloaded videos don't get put in folders nicely
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    pyTivo Discussion Forum Forum Index -> Miscellaneous All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
Site is in NO WAY affiliated with TiVo Inc

Powered by phpBB © 2001, 2005 phpBB Group
phpBB SEO
[ Time: 0.5089s ][ Queries: 15 (0.3682s) ][ Debug on ]