Author: duncan
Date: Tue Jan 8 16:38:45 2008
New Revision: 10270
Log:
Updated and added update from Author Alberto González
Modified:
branches/rel-1-7/freevo/src/video/plugins/youtube.py
branches/rel-1/freevo/src/video/plugins/youtube.py
Modified: branches/rel-1-7/freevo/src/video/plugins/youtube.py
==============================================================================
--- branches/rel-1-7/freevo/src/video/plugins/youtube.py (original)
+++ branches/rel-1-7/freevo/src/video/plugins/youtube.py Tue Jan 8
16:38:45 2008
@@ -1,23 +1,54 @@
-# -*- coding: iso-8859-15 -*-
+# -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------
-# youtube.py - Plugin for download and watch videos of youtube
+# Plugin for download and watch videos of youtube
# -----------------------------------------------------------------------
+# $Id$
#
-# Revision 0.1 - Author Alberto Gonz�lez ([EMAIL PROTECTED])
-# thanks to Sylvain Fabre (cinemovies_trailers.py)
-# and David Sotelo (universal_newlines=1)
-#
-# Please install python-gdata and put youtube-dl in your PATH
-# Add "plugin.activate('video.youtube')" in local_conf.py
-# to activate it
-# In local_conf.py
-# YOUTUBE_VIDEOS = [
-# ("user1", "description1"),
-# ("user2", "description2"),
-# ...
-# ]
-# YOUTUBE_DIR = "/tmp/"
+# Notes:
+# You need to install xxxx from http://
+# You also need yyyy from http://
#
+# thanks to Sylvain Fabre (cinemovies_trailers.py)
+# and David Sotelo (universal_newlines=1)
+#
+# To activate, put the following line in local_conf.py:
+# plugin.activate('video.youtube')
+# YOUTUBE_VIDEOS = [
+# ('user1', 'description1'),
+# ('user2', 'description2'),
+# ...
+# ]
+# YOUTUBE_DIR = '/tmp/'
+#
+# ToDo:
+#
+# -----------------------------------------------------------------------
+#
+# Freevo - A Home Theater PC framework
+# Copyright (C) 2002 Krister Lagerstrom, et al.
+# Please see the file freevo/Docs/CREDITS for a complete list of authors.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
+# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# -----------------------------------------------------------------------
+
+__author__ = 'Author Alberto Gonz�lez'
+__author_email__ = '[EMAIL PROTECTED]'
+__maintainer__ = __author__
+__maintainer_email__ = __author_email__
+__version__ = '0.1b'
import os
import plugin
@@ -49,16 +80,14 @@
Download and watch youtube video
Activate:
- plugin.activate('video.youtube')
-
- Config:
-
- YOUTUBE_VIDEOS = [
- ("user1", "description1"),
- ("user2", "description2"),
- ...
- ]
- YOUTUBE_DIR = "/tmp/"
+ | plugin.activate('video.youtube')
+ |
+ | YOUTUBE_VIDEOS = [
+ | ('user1', 'description1'),
+ | ('user2', 'description2'),
+ | ...
+ | ]
+ | YOUTUBE_DIR = '/tmp/'
"""
def __init__(self):
if not config.USE_NETWORK:
@@ -67,22 +96,39 @@
if not config.YOUTUBE_VIDEOS:
self.reason = 'YOUTUBE_VIDEOS not defined'
return
- if not config.YOUTUBE_DIR:
- config.YOUTUBE_DIR = "/tmp/"
-
plugin.MainMenuPlugin.__init__(self)
+
+ if not os.path.isdir(self.YOUTUBE_DIR):
+ os.mkdir(self.YOUTUBE_DIR,
stat.S_IMODE(os.stat(config.FREEVO_CACHEDIR)[stat.ST_MODE]))
+
+
+ def config(self):
+ """returns the config variables used by this plugin"""
+ return [
+ ('YOUTUBE_VIDEOS', None, 'id and description to get/watch videos
of youtube'),
+ ('YOUTUBE_DIR', config.FREEVO_CACHEDIR + '/youtube', 'directory to
save youtube videos'),
+ ('YOUTUBE-DL', 'youtube-dl', 'The you tube downloader'),
+ ]
+
+
def items(self, parent):
return [ YoutubeVideo(parent) ]
-# Create a VideoItem for play
+
+
class YoutubeVideoItem(VideoItem):
+ """Create a VideoItem for play"""
+
def __init__(self, name, url, parent):
VideoItem.__init__(self, url, parent)
self.name = name
self.type = 'youtube'
-# Main Class
+
+
class YoutubeVideo(Item):
+ """Main Class"""
+
def __init__(self, parent):
# look for a default player
for p in plugin.getbyname(plugin.VIDEO_PLAYER, True):
@@ -92,30 +138,34 @@
self.name = _('Youtube videos')
self.type = 'youtube'
- # Only one action, return user list
+
def actions(self):
+ """Only one action, return user list"""
return [ (self.userlist, 'Video youtube') ]
- # Menu for choose user
+
def userlist(self, arg=None, menuw=None):
+ """Menu for choose user"""
users = []
- for user,description in config.YOUTUBE_VIDEOS:
+ for user, description in config.YOUTUBE_VIDEOS:
users.append(menu.MenuItem(description, self.videolist, (user,
description)))
- menuw.pushmenu(menu.Menu(_("Choose please"), users))
+ menuw.pushmenu(menu.Menu(_('Choose please'), users))
+
- # Menu for video
def videolist(self, arg=None, menuw=None):
- items = video_list(self, _("Retrieving video list"), arg[0])
+ """Menu for video"""
+ items = video_list(self, _('Retrieving video list'), arg[0])
menuw.pushmenu(menu.Menu(_('Videos available'), items))
- # Download video (if necessary) and watch it
+
def downloadvideo(self, arg=None, menuw=None):
- filename = config.YOUTUBE_DIR + '/' + arg[1].replace("-","_") + ".flv"
+ """Download video (if necessary) and watch it"""
+ filename = config.YOUTUBE_DIR + '/' + arg[1].replace('-', '_') +
'.flv'
if not os.path.exists(filename):
- box = PopupBox(text=_("Downloading video"), width=950)
- cmd = 'youtube-dl -o ' + config.YOUTUBE_DIR + '/' +
arg[1].replace("-","_")
- cmd = cmd + '.flv "http://www.youtube.com/watch?v=' + arg[1] + '"'
- proceso = Popen(cmd, shell=True, bufsize=1024,
stdout=subprocess.PIPE,universal_newlines=1)
+ box = PopupBox(text=_('Downloading video'), width=950)
+ cmd = config.YOUTUBE-DL + ' -o ' + config.YOUTUBE_DIR + '/' +
arg[1].replace('-', '_')
+ cmd += '.flv "http://www.youtube.com/watch?v=' + arg[1] + '"'
+ proceso = Popen(cmd, shell=True, bufsize=1024,
stdout=subprocess.PIPE, universal_newlines=1)
follow = proceso.stdout
while proceso.poll() == None:
mess = follow.readline()
@@ -126,20 +176,21 @@
box.destroy()
# Create a fake VideoItem
- playvideo2 = YoutubeVideoItem(_("bla"), filename, self)
+ playvideo2 = YoutubeVideoItem(_('bla'), filename, self)
playvideo2.player = self.player
playvideo2.player_rating = 10
playvideo2.menuw = menuw
playvideo2.play()
-# Get the video list for a specific user
+
def video_list(parent, title, user):
+ """Get the video list for a specific user"""
items = []
- feed = "http://gdata.youtube.com/feeds/users/" + user +
"/uploads?orderby=updated"
+ feed = 'http://gdata.youtube.com/feeds/users/' + user +
'/uploads?orderby=updated'
- service = gdata.service.GDataService(server="gdata.youtube.com")
+ service = gdata.service.GDataService(server='gdata.youtube.com')
for video in service.GetFeed(feed).entry:
- date = video.published.text.split("T")
- id = video.link[1].href.split("watch?v=");
- items.append(menu.MenuItem(date[0] + " " + video.title.text,
parent.downloadvideo, (video.title.text, id[1])))
+ date = video.published.text.split('T')
+ id = video.link[1].href.split('watch?v=');
+ items.append(menu.MenuItem(date[0] + ' ' + video.title.text,
parent.downloadvideo, (video.title.text, id[1])))
return items
Modified: branches/rel-1/freevo/src/video/plugins/youtube.py
==============================================================================
--- branches/rel-1/freevo/src/video/plugins/youtube.py (original)
+++ branches/rel-1/freevo/src/video/plugins/youtube.py Tue Jan 8 16:38:45 2008
@@ -1,23 +1,54 @@
-# -*- coding: iso-8859-15 -*-
+# -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------
-# youtube.py - Plugin for download and watch videos of youtube
+# Plugin for download and watch videos of youtube
# -----------------------------------------------------------------------
+# $Id$
#
-# Revision 0.1 - Author Alberto Gonz�lez ([EMAIL PROTECTED])
-# thanks to Sylvain Fabre (cinemovies_trailers.py)
-# and David Sotelo (universal_newlines=1)
-#
-# Please install python-gdata and put youtube-dl in your PATH
-# Add "plugin.activate('video.youtube')" in local_conf.py
-# to activate it
-# In local_conf.py
-# YOUTUBE_VIDEOS = [
-# ("user1", "description1"),
-# ("user2", "description2"),
-# ...
-# ]
-# YOUTUBE_DIR = "/tmp/"
+# Notes:
+# You need to install xxxx from http://
+# You also need yyyy from http://
#
+# thanks to Sylvain Fabre (cinemovies_trailers.py)
+# and David Sotelo (universal_newlines=1)
+#
+# To activate, put the following line in local_conf.py:
+# plugin.activate('video.youtube')
+# YOUTUBE_VIDEOS = [
+# ('user1', 'description1'),
+# ('user2', 'description2'),
+# ...
+# ]
+# YOUTUBE_DIR = '/tmp/'
+#
+# ToDo:
+#
+# -----------------------------------------------------------------------
+#
+# Freevo - A Home Theater PC framework
+# Copyright (C) 2002 Krister Lagerstrom, et al.
+# Please see the file freevo/Docs/CREDITS for a complete list of authors.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
+# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# -----------------------------------------------------------------------
+
+__author__ = 'Author Alberto Gonz�lez'
+__author_email__ = '[EMAIL PROTECTED]'
+__maintainer__ = __author__
+__maintainer_email__ = __author_email__
+__version__ = '0.1b'
import os
import plugin
@@ -49,16 +80,14 @@
Download and watch youtube video
Activate:
- plugin.activate('video.youtube')
-
- Config:
-
- YOUTUBE_VIDEOS = [
- ("user1", "description1"),
- ("user2", "description2"),
- ...
- ]
- YOUTUBE_DIR = "/tmp/"
+ | plugin.activate('video.youtube')
+ |
+ | YOUTUBE_VIDEOS = [
+ | ('user1', 'description1'),
+ | ('user2', 'description2'),
+ | ...
+ | ]
+ | YOUTUBE_DIR = '/tmp/'
"""
def __init__(self):
if not config.USE_NETWORK:
@@ -67,22 +96,39 @@
if not config.YOUTUBE_VIDEOS:
self.reason = 'YOUTUBE_VIDEOS not defined'
return
- if not config.YOUTUBE_DIR:
- config.YOUTUBE_DIR = "/tmp/"
-
plugin.MainMenuPlugin.__init__(self)
+
+ if not os.path.isdir(self.YOUTUBE_DIR):
+ os.mkdir(self.YOUTUBE_DIR,
stat.S_IMODE(os.stat(config.FREEVO_CACHEDIR)[stat.ST_MODE]))
+
+
+ def config(self):
+ """returns the config variables used by this plugin"""
+ return [
+ ('YOUTUBE_VIDEOS', None, 'id and description to get/watch videos
of youtube'),
+ ('YOUTUBE_DIR', config.FREEVO_CACHEDIR + '/youtube', 'directory to
save youtube videos'),
+ ('YOUTUBE-DL', 'youtube-dl', 'The you tube downloader'),
+ ]
+
+
def items(self, parent):
return [ YoutubeVideo(parent) ]
-# Create a VideoItem for play
+
+
class YoutubeVideoItem(VideoItem):
+ """Create a VideoItem for play"""
+
def __init__(self, name, url, parent):
VideoItem.__init__(self, url, parent)
self.name = name
self.type = 'youtube'
-# Main Class
+
+
class YoutubeVideo(Item):
+ """Main Class"""
+
def __init__(self, parent):
# look for a default player
for p in plugin.getbyname(plugin.VIDEO_PLAYER, True):
@@ -92,30 +138,34 @@
self.name = _('Youtube videos')
self.type = 'youtube'
- # Only one action, return user list
+
def actions(self):
+ """Only one action, return user list"""
return [ (self.userlist, 'Video youtube') ]
- # Menu for choose user
+
def userlist(self, arg=None, menuw=None):
+ """Menu for choose user"""
users = []
- for user,description in config.YOUTUBE_VIDEOS:
+ for user, description in config.YOUTUBE_VIDEOS:
users.append(menu.MenuItem(description, self.videolist, (user,
description)))
- menuw.pushmenu(menu.Menu(_("Choose please"), users))
+ menuw.pushmenu(menu.Menu(_('Choose please'), users))
+
- # Menu for video
def videolist(self, arg=None, menuw=None):
- items = video_list(self, _("Retrieving video list"), arg[0])
+ """Menu for video"""
+ items = video_list(self, _('Retrieving video list'), arg[0])
menuw.pushmenu(menu.Menu(_('Videos available'), items))
- # Download video (if necessary) and watch it
+
def downloadvideo(self, arg=None, menuw=None):
- filename = config.YOUTUBE_DIR + '/' + arg[1].replace("-","_") + ".flv"
+ """Download video (if necessary) and watch it"""
+ filename = config.YOUTUBE_DIR + '/' + arg[1].replace('-', '_') +
'.flv'
if not os.path.exists(filename):
- box = PopupBox(text=_("Downloading video"), width=950)
- cmd = 'youtube-dl -o ' + config.YOUTUBE_DIR + '/' +
arg[1].replace("-","_")
- cmd = cmd + '.flv "http://www.youtube.com/watch?v=' + arg[1] + '"'
- proceso = Popen(cmd, shell=True, bufsize=1024,
stdout=subprocess.PIPE,universal_newlines=1)
+ box = PopupBox(text=_('Downloading video'), width=950)
+ cmd = config.YOUTUBE-DL + ' -o ' + config.YOUTUBE_DIR + '/' +
arg[1].replace('-', '_')
+ cmd += '.flv "http://www.youtube.com/watch?v=' + arg[1] + '"'
+ proceso = Popen(cmd, shell=True, bufsize=1024,
stdout=subprocess.PIPE, universal_newlines=1)
follow = proceso.stdout
while proceso.poll() == None:
mess = follow.readline()
@@ -126,20 +176,21 @@
box.destroy()
# Create a fake VideoItem
- playvideo2 = YoutubeVideoItem(_("bla"), filename, self)
+ playvideo2 = YoutubeVideoItem(_('bla'), filename, self)
playvideo2.player = self.player
playvideo2.player_rating = 10
playvideo2.menuw = menuw
playvideo2.play()
-# Get the video list for a specific user
+
def video_list(parent, title, user):
+ """Get the video list for a specific user"""
items = []
- feed = "http://gdata.youtube.com/feeds/users/" + user +
"/uploads?orderby=updated"
+ feed = 'http://gdata.youtube.com/feeds/users/' + user +
'/uploads?orderby=updated'
- service = gdata.service.GDataService(server="gdata.youtube.com")
+ service = gdata.service.GDataService(server='gdata.youtube.com')
for video in service.GetFeed(feed).entry:
- date = video.published.text.split("T")
- id = video.link[1].href.split("watch?v=");
- items.append(menu.MenuItem(date[0] + " " + video.title.text,
parent.downloadvideo, (video.title.text, id[1])))
+ date = video.published.text.split('T')
+ id = video.link[1].href.split('watch?v=');
+ items.append(menu.MenuItem(date[0] + ' ' + video.title.text,
parent.downloadvideo, (video.title.text, id[1])))
return items
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog