Author: duncan
Date: Tue Aug 21 15:36:50 2007
New Revision: 9840
Log:
[ 1778934 ] update of recordings_manager to reuse VideoItem
Patch from Tanja Kotthaus applied
Modified:
branches/rel-1/freevo/src/tv/plugins/recordings_manager.py
branches/rel-1/freevo/src/video/plugins/mover.py
branches/rel-1/freevo/src/video/plugins/mplayer.py
Modified: branches/rel-1/freevo/src/tv/plugins/recordings_manager.py
==============================================================================
--- branches/rel-1/freevo/src/tv/plugins/recordings_manager.py (original)
+++ branches/rel-1/freevo/src/tv/plugins/recordings_manager.py Tue Aug 21
15:36:50 2007
@@ -49,13 +49,12 @@
import util
-import skin
import plugin
-import osd
import fxditem
-from item import Item, FileInformation
+from item import Item
from playlist import Playlist
+from directory import DirItem
from event import *
from gui import ConfirmBox, AlertBox, ProgressBox
from menu import MenuItem, Menu
@@ -97,9 +96,21 @@
class PluginInterface(plugin.MainMenuPlugin):
"""
- Plugin interface for the Manage Recordings TV menu and
- the disk space reclaiming feature.
+ Plugin to browse the TV recordings directory based on series rather than
+ just a flat view of the recordings.
+ Programs not in a series are placed at the top level, while programs that
+ are a member of a series are placed in a series menu and the menu placed
+ at the top level.
+
+ Activate with:
+ plugin.activate('tv.recordings_manager',level=5)
+ This also automatically activates tv.recordings_manager.DiscManager.
+
+ You probably want also to deactivate the generic view_recordings plugin,
+ which is kind of redundant if you use the recordings_manager plugin:
+ plugin.remove('tv.view_recordings')
"""
+
def __init__(self):
"""
normal plugin init, but sets _type to 'mainmenu_tv'
@@ -128,8 +139,7 @@
('TVRM_MINIMUM_DISK_FREE', 2048, 'Minimum amount of disk space
that must be available at all times in MB'),
('TVRM_CONSIDER_UNWATCHED_AFTER', 45, 'Number of days after which
to consider deleting unwatched shows if space is required'),
('TVRM_EPISODE_FROM_PLOT', None, 'Regular expression to extract
the episode name from the plot'),
- ('TVRM_EPISODE_TIME_FORMAT', '%c', 'When the episode name cannot
be found use timestamp'),
- ('TVRM_ADD_VIDEO_ACTIONS', False, 'Append VideoItem actions to the
end a RecordedProgramItem list of actions'),
+ ('TVRM_EPISODE_TIME_FORMAT', '%c', 'When the episode name cannot
be found use timestamp in this format'),
]
@@ -161,7 +171,7 @@
"""
return a list of actions for this item
"""
- items = [ (self.browse, _('Browse directory')), self.blue_action]
+ items = [(self.browse, _('Browse directory')) , self.blue_action]
return items
@@ -259,17 +269,18 @@
def configure(self, arg=None, menuw=None):
- items = [ MenuItem(_('Sort by') + u'\t' + _(sorting_methods[sorting]),
- self.configure_sorting, 'sorting'),
- MenuItem(_('Reverse sort')+ u'\t' +
self.configure_get_icon(sorting_reversed),
- self.configure_sorting_reversed,
'sorting_reversed'),
- MenuItem(_('Sort series by') + u'\t' +
_(series_sorting_methods[series_sorting]),
- self.configure_sorting, 'series_sorting'),
- MenuItem(_('Reverse series sort')+ u'\t' +
self.configure_get_icon(series_sorting_reversed),
- self.configure_sorting_reversed,
'series_sorting_reversed'),
- MenuItem(_('Status order') + u'\t' +
_(status_order_methods[status_order]),
- self.configure_sorting, 'status_order')
- ]
+ items = [
+ MenuItem(_('Sort by') + u'\t' + _(sorting_methods[sorting]),
+ self.configure_sorting, 'sorting'),
+ MenuItem(_('Reverse sort')+ u'\t' +
self.configure_get_icon(sorting_reversed),
+ self.configure_sorting_reversed, 'sorting_reversed'),
+ MenuItem(_('Sort series by') + u'\t' +
_(series_sorting_methods[series_sorting]),
+ self.configure_sorting, 'series_sorting'),
+ MenuItem(_('Reverse series sort')+ u'\t' +
self.configure_get_icon(series_sorting_reversed),
+ self.configure_sorting_reversed, 'series_sorting_reversed'),
+ MenuItem(_('Status order') + u'\t' +
_(status_order_methods[status_order]),
+ self.configure_sorting, 'status_order')
+ ]
m = Menu(_('Configure'), items)
m.table = (50, 50)
menuw.pushmenu(m)
@@ -343,18 +354,16 @@
# Program Class
# ======================================================================
-class RecordedProgramItem(Item):
+class RecordedProgramItem(VideoItem):
"""
Class to represent a recorded TV program.
"""
def __init__(self, name, video_item):
- Item.__init__(self, None, skin_type = 'tv')
- self.set_url(None)
- self.type='video'
- self.name = name
- self.filename = video_item.filename
+ VideoItem.__init__(self, url=video_item.url, parent=video_item.parent)
self.video_item = video_item
-
+ self.name = name
+ self.files = video_item.files
+ self.parent = DirItem(config.TV_RECORD_DIR, None)
keep = self.video_item['keep']
if not keep:
keep = False
@@ -384,16 +393,10 @@
"""
return the default action
"""
- actions = [
- (self.play, _('Play')),
- (self.view_details, _('Full Description')),
- (self.confirm_delete, _('Delete')),
- (self.mark_to_keep, self.keep and _('Unmark to Keep') or _('Mark
to Keep')),
- (self.mark_as_watched, self.watched and _('Unmark as Watched') or
_('Mark as Watched'))
- ]
- if config.TVRM_ADD_VIDEO_ACTIONS:
- actions += self.video_item.actions()[1:] # Remove 'Play' as we've
already got it.
- return actions
+ items = self.video_item.actions()
+ items.append((self.mark_to_keep, self.keep and _('Unmark to Keep') or
_('Mark to Keep')))
+ items.append((self.mark_as_watched, self.watched and _('Unmark as
Watched') or _('Mark as Watched')))
+ return items
def play(self, arg=None, menuw=None):
@@ -407,26 +410,6 @@
self.set_icon()
- def confirm_delete(self, arg=None, menuw=None):
- """
- Confirm whether the user really wants to delete this program.
- """
- self.menuw = menuw
- ConfirmBox(text=_('Do you wish to delete\n \'%s\'?') % self.name,
- handler=self.delete, default_choice=1,
- handler_message=_('Deleting...')).show()
-
-
- def delete(self):
- """
- Delete the recorded program.
- """
- # delete the file
- self.video_item.files.delete()
- if self.menuw:
- self.menuw.delete_submenu(True, True)
-
-
def mark_to_keep(self, arg=None, menuw=None):
"""
Toggle whether this program should be kept.
@@ -451,21 +434,6 @@
menuw.refresh(reload=True)
- def view_details(self, arg=None, menuw=None):
- ShowDetails(menuw, self)
-
-
- def display_submenu(self, arg=None, menuw=None):
- """
- Open the submenu for this item
- """
- if not menuw:
- return
- # this tries to imitated freevo's internal way of creating submenus
- menuw.make_submenu(_('Recordings Menu'), self.actions(), self)
- menuw.show()
-
-
def set_name_to_episode(self):
"""
Set the name of this recorded program item to the name of
@@ -793,7 +761,14 @@
class DiskManager(plugin.DaemonPlugin):
"""
- Class to ensure a minimum amount of disk space is always available.
+ This plugin automatically removes recordings
+ when disc space is getting low.
+
+ It is automatically activated by the tv.recordings_manager plugin,
+ and should not be used standalone.
+ For more information read the details for tv.recordings_manager.
+
+ freevo plugins -i tv.recordings_manager
"""
def __init__(self, required_space):
plugin.DaemonPlugin.__init__(self)
@@ -852,6 +827,7 @@
self.menuw.event_context == rc.get_singleton().context:
self.obj.browse(menuw=self.menuw, arg='update')
+
def update_recordings(self):
"""
Update the list of recordings.
@@ -865,6 +841,7 @@
series = {}
+
recordings = fxditem.mimetype.get(None, files)
for recorded_item in recordings:
rpitem = RecordedProgramItem(recorded_item.name, recorded_item)
@@ -974,114 +951,3 @@
elif watched:
order = orders[STATUS_ORDER_WATCHED]
return order
-
-
-import skin
-# Create the skin_object object
-skin_object = skin.get_singleton()
-skin_object.register('tvguideinfo', ('screen', 'info', 'scrollabletext',
'plugin'))
-
-
-class ShowDetails:
- """
- Screen to show the details of the TV program
- """
- def __init__(self, menuw, episode):
- if episode is None:
- name = _('No Information Available')
- sub_title = ''
- time = ''
- description = ''
- else:
- self.episode = episode
- name = episode.name
- sub_title = episode.video_item['tagline']
- desc = episode.video_item['plot']
- # gather the infos and construct the description text
- if sub_title:
- # subtitle + newline + description
- description = u'"' + sub_title + u'"\n' + desc
- else:
- # or just the description, if there is no subtitle
- description = desc
-
- # maybe there is more infos to add (categories, advisories,
ratings)
- if hasattr(episode.video_item, 'categories'):
- description += u'\n'
- for category in episode.video_item.categories:
- description += u'\n' + _('Category : ') + category
-
- if hasattr(episode.video_item, 'advisories'):
- description += u'\n'
- for advisory in episode.video_item.advisories:
- description += u'\n' + _('Advisory : ') + advisory
-
- if hasattr(episode.video_item, 'ratings'):
- description += u'\n'
- for system,value in episode.video_item.ratings.items():
- description += u'\n' + _('Rating') + u'(' + system + u') :
' + value
-
- # that's all, we can show this to the user
- self.name = name
- self.scrollable_text = skin.ScrollableText(description)
- self.visible = True
-
- self.menuw = menuw
- self.menuw.hide(clear=False)
-
- # this activates the eventhandler and the context of this class
- rc.app(self)
-
- skin_object.draw('tvguideinfo', self)
-
-
-
- def getattr(self, name):
- if name == 'title':
- return self.name
-
- if self.episode:
- return self.episode.getattr(name)
-
- return u''
-
-
- def eventhandler(self, event, menuw=None):
- """
- eventhandler for the programm description display
- """
- if event in ('MENU_SELECT', 'MENU_BACK_ONE_MENU'):
- # leave the description display and return to the previous menu
- self.menuw.show()
- # we do not need to call rc.app(None) here,
- # because that is done by menuw.show(),
- # but we need to set the context manually,
- # because rc.app(None) sets it always to 'menu'
- rc.set_context(self.menuw.get_event_context())
- return True
- elif event == 'MENU_SUBMENU':
- if hasattr(self.menuw.menustack[-1],'is_submenu'):
- # the last menu has been a submenu, we just have to show it
- self.menuw.show()
- rc.set_context(self.menuw.get_event_context())
- else:
- # we have to create the submenu
- self.episode.display_submenu(menuw=self.menuw)
- return True
- elif event == 'MENU_UP':
- # scroll the description up
- self.scrollable_text.scroll(True)
- skin_object.draw('tvguideinfo', self)
- return True
- elif event == 'MENU_DOWN':
- # scroll the description down
- self.scrollable_text.scroll(False)
- skin_object.draw('tvguideinfo', self)
- return True
- elif event == 'MENU_PLAY_ITEM':
- self.menuw.show()
- rc.set_context(self.menuw.get_event_context())
- self.episode.play(menuw=self.menuw)
- return True
- else:
- return False
Modified: branches/rel-1/freevo/src/video/plugins/mover.py
==============================================================================
--- branches/rel-1/freevo/src/video/plugins/mover.py (original)
+++ branches/rel-1/freevo/src/video/plugins/mover.py Tue Aug 21 15:36:50 2007
@@ -75,26 +75,37 @@
"""
def __init__(self, from_dir, to_dir, recursive=False, makedirs=False):
plugin.ItemPlugin.__init__(self)
- self.from_dir = from_dir
- self.to_dir = to_dir
+
+ self.from_dir = from_dir.rstrip(os.sep)
+ self.to_dir = to_dir.rstrip(os.sep)
self.recursive = recursive
self.makedirs = makedirs
def actions(self, item):
self.item = item
- if ( item.type == 'video'
- and item.mode == 'file'
- and item.parent.type == 'dir'
- # don't bother moving to current-dir
- and self.to_dir != os.path.dirname(self.item.filename)
- # recursive
- and ( ( self.recursive
- and os.path.commonprefix( ( item.parent.dir,
self.from_dir)) == self.from_dir )
- # or absolute
- or ( item.parent.dir == self.from_dir))):
- return [ (self.mover_to_series,
- _('Move to [%s]') % os.path.basename(self.to_dir)) ]
- return []
+ if not item.type == 'video':
+ return []
+ if not item.mode == 'file':
+ return []
+ if not item.parent.type == 'dir':
+ return []
+ # don't bother moving to current-dir
+ if self.to_dir == os.path.dirname(self.item.filename):
+ return []
+
+ # check if we are inside the from_dir:
+ if self.recursive:
+ # recursive
+ prefix = os.path.commonprefix((item.parent.dir, self.from_dir))
+ if not prefix == self.from_dir:
+ return []
+ else:
+ # or absolute
+ if not item.parent.dir == self.from_dir:
+ return []
+
+ return [ (self.mover_to_series, _('Move to [%s]') %
os.path.basename(self.to_dir)) ]
+
def mover_to_series(self, arg=None, menuw=None):
# make to_dir an absolute path
Modified: branches/rel-1/freevo/src/video/plugins/mplayer.py
==============================================================================
--- branches/rel-1/freevo/src/video/plugins/mplayer.py (original)
+++ branches/rel-1/freevo/src/video/plugins/mplayer.py Tue Aug 21 15:36:50 2007
@@ -88,7 +88,7 @@
if item.mode in ('dvd', 'vcd'):
return 2
if item.mimetype in config.VIDEO_MPLAYER_SUFFIX:
- if config.DEBUG >= 2:
+ if config.DEBUG >= 4:
for d in dir(item):
print '%s: %s' % (d, eval('item.%s' % d))
for d in dir(item.info):
@@ -145,10 +145,10 @@
set_vcodec = True
# Build the MPlayer command
- command = [ '--prio=%s' % config.MPLAYER_NICE, config.MPLAYER_CMD ]
- command += [ '-slave' ]
+ command = ['--prio=%s' % config.MPLAYER_NICE, config.MPLAYER_CMD]
+ command += ['-slave']
command += config.MPLAYER_ARGS_DEF.split(' ')
- command += [ '-ao'] + config.MPLAYER_AO_DEV.split(' ')
+ command += ['-ao'] + config.MPLAYER_AO_DEV.split(' ')
additional_args = []
@@ -161,62 +161,62 @@
if hasattr(item, 'mplayer_audio_broken') and
item.mplayer_audio_broken:
print '*** dvd audio broken, try without alang ***'
else:
- additional_args += [ '-alang', config.DVD_LANG_PREF ]
+ additional_args += ['-alang', config.DVD_LANG_PREF]
if config.DVD_SUBTITLE_PREF:
# Only use if defined since it will always turn on subtitles
# if defined
- additional_args += [ '-slang', config.DVD_SUBTITLE_PREF ]
+ additional_args += ['-slang', config.DVD_SUBTITLE_PREF]
if hasattr(item.media, 'devicename') and mode != 'file':
- additional_args += [ '-dvd-device', item.media.devicename ]
+ additional_args += ['-dvd-device', item.media.devicename]
elif mode == 'dvd':
# dvd on harddisc
- additional_args += [ '-dvd-device', item.filename ]
+ additional_args += ['-dvd-device', item.filename]
url = url[:6] + url[url.rfind('/')+1:]
if item.media and hasattr(item.media,'devicename'):
- additional_args += [ '-cdrom-device', item.media.devicename ]
+ additional_args += ['-cdrom-device', item.media.devicename]
if item.selected_subtitle == -1:
- additional_args += [ '-noautosub' ]
+ additional_args += ['-noautosub']
elif item.selected_subtitle != None:
if mode == 'file':
if os.path.isfile(os.path.splitext(item.filename)[0]+'.idx'):
- additional_args += [ '-vobsubid',
str(item.selected_subtitle) ]
+ additional_args += ['-vobsubid',
str(item.selected_subtitle)]
else:
- additional_args += [ '-sid', str(item.selected_subtitle) ]
+ additional_args += ['-sid', str(item.selected_subtitle)]
else:
- additional_args += [ '-sid', str(item.selected_subtitle) ]
+ additional_args += ['-sid', str(item.selected_subtitle)]
if item.selected_audio != None:
- additional_args += [ '-aid', str(item.selected_audio) ]
+ additional_args += ['-aid', str(item.selected_audio)]
# This comes from the bilingual language selection menu
if hasattr(item, 'selected_language') and item.selected_language:
if item.selected_language == 'left':
- additional_args += [ '-af', 'pan=2:1:1:0:0' ]
+ additional_args += ['-af', 'pan=2:1:1:0:0']
elif item.selected_language == 'right':
- additional_args += [ '-af', 'pan=2:0:0:1:1' ]
+ additional_args += ['-af', 'pan=2:0:0:1:1']
if not set_vcodec:
if item['deinterlace'] and config.MPLAYER_VF_INTERLACED:
- additional_args += [ '-vf', config.MPLAYER_VF_INTERLACED ]
+ additional_args += ['-vf', config.MPLAYER_VF_INTERLACED]
elif config.MPLAYER_VF_PROGRESSIVE:
- additional_args += [ '-vf', config.MPLAYER_VF_PROGRESSIVE ]
+ additional_args += ['-vf', config.MPLAYER_VF_PROGRESSIVE]
if hasattr(config, 'VIDEO_FIELD_DOMINANCE') and
config.VIDEO_FIELD_DOMINANCE != None:
- additional_args += [ '-field-dominance', '%d' %
int(item['field-dominance']) ]
+ additional_args += ['-field-dominance', '%d' %
int(item['field-dominance'])]
if os.path.isfile(os.path.splitext(item.filename)[0]+'.edl'):
- additional_args += [ '-edl',
str(os.path.splitext(item.filename)[0]+'.edl') ]
+ additional_args += ['-edl',
str(os.path.splitext(item.filename)[0]+'.edl')]
mode = item.mimetype
if not config.MPLAYER_ARGS.has_key(mode):
mode = 'default'
if config.CHILDAPP_DEBUG:
- command += [ '-v' ]
+ command += ['-v']
# Mplayer command and standard arguments
if set_vcodec:
@@ -224,9 +224,9 @@
bobdeint='bobdeint'
else:
bobdeint='nobobdeint'
- command += [ '-vo', 'xvmc:%s' % bobdeint, '-vc', 'ffmpeg12mc' ]
+ command += ['-vo', 'xvmc:%s' % bobdeint, '-vc', 'ffmpeg12mc']
else:
- command += [ '-vo', config.MPLAYER_VO_DEV +
config.MPLAYER_VO_DEV_OPTS ]
+ command += ['-vo', config.MPLAYER_VO_DEV +
config.MPLAYER_VO_DEV_OPTS]
# mode specific args
command += config.MPLAYER_ARGS[mode].split(' ')
@@ -253,8 +253,8 @@
# correct avi delay based on kaa.metadata settings
if config.MPLAYER_SET_AUDIO_DELAY and item.info.has_key('delay') and \
item.info['delay'] > 0:
- command += [ '-mc', str(int(item.info['delay'])+1), '-delay',
- '-' + str(item.info['delay']) ]
+ command += ['-mc', str(int(item.info['delay'])+1), '-delay',
+ '-' + str(item.info['delay'])]
while '' in command:
command.remove('')
@@ -271,7 +271,7 @@
(x1, y1, x2, y2) = self.get_crop(crop_point, x1, y1, x2, y2)
if x1 < 1000 and x2 < 1000:
- command = command + [ '-vf' , 'crop=%s:%s:%s:%s' % (x2-x1,
y2-y1, x1, y1) ]
+ command = command + ['-vf' , 'crop=%s:%s:%s:%s' % (x2-x1,
y2-y1, x1, y1)]
_debug_('crop=%s:%s:%s:%s' % (x2-x1, y2-y1, x1, y1))
@@ -368,7 +368,7 @@
self.play(self.options, self.item)
return True
- if event in ( PLAY_END, USER_END ):
+ if event in (PLAY_END, USER_END):
self.stop()
return self.item.eventhandler(event)
@@ -455,15 +455,15 @@
elif (arg == '-vf'):
next_is_vf=True
else:
- ret += [ arg ]
+ ret += [arg]
if vf:
- return ret + [ '-vf', vf[1:] ]
+ return ret + ['-vf', vf[1:]]
return ret
def get_crop(self, pos, x1, y1, x2, y2):
crop_cmd = [config.MPLAYER_CMD, '-ao', 'null', '-vo', 'null',
'-slave', '-nolirc',
- '-ss', '%s' % pos, '-frames', '10', '-vf', 'cropdetect' ]
+ '-ss', '%s' % pos, '-frames', '10', '-vf', 'cropdetect']
crop_cmd.append(self.item.url)
child = popen2.Popen3(self.sort_filter(crop_cmd), 1, 100)
exp = re.compile('^.*-vf crop=([0-9]*):([0-9]*):([0-9]*):([0-9]*).*')
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog