Hi,
Some time ago I said I wanted to work on the favorites and scheduled
plug-ins. Well I finally got time to do so. So attached you can find the
new scheduled TV plug-in.
I also changed the tvserver. This was needed because when an recording
was removed and the new list was retrieved, it was still the 'old' list
(including the deleted item). Apparently the tvserver was not synced
yet.
I have also a question. I see that in the freevo-tvserver the scheduled
recordings are not really removed. They just get the 'deleted' or
'missed' status. Is this behavior wanted? If so, could you explain why?
Now I will continu with the favorites plug-in.
Best regards,
Jose
Index: tvserver.py
===================================================================
--- tvserver.py (revision 9373)
+++ tvserver.py (working copy)
@@ -269,6 +269,9 @@
if not self.server:
return False, 'Recordserver unavailable'
self.rpc('home-theatre.recording.remove', id)
+ #Wait until the list is refreshed before we return,
+ # otherwise the user can get an oldlist!
+ self.wait_on_list()
# FIXME: make it possible to return a failure
return True, 'Removed'
# -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------
# scheduled.py - A plugin to view your scheduled recordings.
# -----------------------------------------------------------------------
# $Id: scheduled.py 7806 2005-11-23 19:27:23Z dmeyer $
#
# -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework
# Copyright (C) 2002-2005 Krister Lagerstrom, Dirk Meyer, et al.
# Please see the file doc/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
#
# ----------------------------------------------------------------------- */
# python imports
import time
# kaa imports
import kaa.epg
from kaa.strutils import unicode_to_str
# freevo ui imports
from freevo.ui.config import config
from freevo.ui.menu import Menu, ActionItem, Action, Item
from freevo.ui.mainmenu import MainMenuPlugin
from freevo.ui.application import MessageWindow
# freevo core imports
import freevo.ipc
# get tvserver interface
tvserver = freevo.ipc.Instance('freevo').tvserver
class RecordingItem(Item):
"""
A recording item to remove/watch a scheduled recording.
"""
def __init__(self, channel, start, stop, parent):
Item.__init__(self, parent)
self.scheduled = tvserver.recordings.get(channel, start, stop)
if self.scheduled.description.has_key('title'):
self.title = self.scheduled.description['title']
self.name = self.scheduled.description['title']
else:
self.name = self.title = ''
self.channel = channel
self.start = start
self.stop = stop
def __unicode__(self):
"""
return as unicode for debug
"""
bt = time.localtime(self.start) # Beginning time tuple
et = time.localtime(self.stop) # End time tuple
begins = '%s-%02d-%02d %02d:%02d' % (bt[0], bt[1], bt[2], bt[3], bt[4])
ends = '%s-%02d-%02d %02d:%02d' % (et[0], et[1], et[2], et[3], et[4])
return u'%s to %s %3s ' % (begins, ends, self.channel) + \
self.title
def __str__(self):
"""
return as string for debug
"""
return unicode_to_str(self.__unicode__())
def __cmp__(self, other):
"""
compare function, return 0 if the objects are identical, 1 otherwise
"""
if not isinstance(other, (RecordingItem)):
return 1
return self.start != other.start or \
self.stop != other.stop or \
self.channel != other.channel
def __getitem__(self, key):
"""
return the specific attribute as string or an empty string
"""
if key == 'start':
return unicode(time.strftime(config.tv.timeformat,
time.localtime(self.start)))
if key == 'stop':
return unicode(time.strftime(config.tv.timeformat,
time.localtime(self.stop)))
if key == 'date':
return unicode(time.strftime(config.tv.dateformat,
time.localtime(self.start)))
if key == 'time':
return self['start'] + u' - ' + self['stop']
if key == 'channel':
return self.channel
return Item.__getitem__(self, key)
def actions(self):
"""
return a list of possible actions on this item.
"""
return [ Action(_('Show recording menu'), self.submenu) ]
def submenu(self):
"""
show a submenu for this item
"""
items = []
if self.start < time.time() + 10 and \
self.scheduled.status in ('recording', 'saved'):
items.append(ActionItem(_('Watch recording'), self,
self.watch_recording))
if self.stop > time.time():
if self.start < time.time():
items.append(ActionItem(_('Stop recording'), self,
self.remove))
else:
items.append(ActionItem(_('Remove recording'), self,
self.remove))
s = Menu(self, items, type = 'tv program menu')
s.submenu = True
s.infoitem = self
self.pushmenu(s)
def watch_recording(self):
MessageWindow('Not implemented yet').show()
def remove(self):
(result, msg) = tvserver.recordings.remove(self.scheduled.id)
if result:
MessageWindow(_('"%s" has been removed as recording') % \
self.title).show()
else:
MessageWindow(_('Scheduling Failed')+(': %s' % msg)).show()
self.get_menustack().delete_submenu()
class PluginInterface(MainMenuPlugin):
"""
This plugin is used to display your scheduled recordings.
"""
def scheduled(self, parent):
"""
Show all scheduled recordings.
"""
self.parent = parent
items = self.get_items(parent)
if items:
self.menu = Menu(_('View scheduled recordings'), items, type='tv program menu',
reload_func = self.reload_scheduled)
parent.pushmenu(self.menu)
else:
MessageWindow(_('There are no scheduled recordings.')).show()
def reload_scheduled(self):
items = self.get_items(self.parent)
if items:
self.menu.set_items(items)
else:
self.parent.get_menustack().back_one_menu()
def get_items(self, parent):
items = []
rec = tvserver.recordings.list()
for p in rec:
scheduled = tvserver.recordings.get(p.channel, p.start, p.stop)
if scheduled and not scheduled.status in ('deleted', 'missed'):
items.append(RecordingItem(parent=parent, channel=p.channel,
start=p.start, stop=p.stop))
return items
def items(self, parent):
"""
Return the main menu item.
"""
return [ ActionItem(_('View scheduled recordings'), parent, self.scheduled) ]
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-devel