Update of /cvsroot/freevo/freevo/src/plugins
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2764
Modified Files:
mediamenu.py rom_drives.py unpack.py
Log Message:
switch to new mediainfo module
Index: unpack.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/plugins/unpack.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** unpack.py 25 Jan 2005 20:19:29 -0000 1.1
--- unpack.py 10 Apr 2005 18:02:09 -0000 1.2
***************
*** 102,111 ****
! def get(self, parent, files):
"""
Return a list of items based on the files
"""
items = []
! for file in util.find_matches(files, self.suffix()):
! items.append(ArchiveItem(file, parent))
return items
--- 102,111 ----
! def get(self, parent, listing):
"""
Return a list of items based on the files
"""
items = []
! for file in listing.match_suffix(self.suffix()):
! items.append(ArchiveItem(file.filename, parent))
return items
Index: rom_drives.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/plugins/rom_drives.py,v
retrieving revision 1.76
retrieving revision 1.77
diff -C2 -d -r1.76 -r1.77
*** rom_drives.py 23 Jan 2005 16:32:27 -0000 1.76
--- rom_drives.py 10 Apr 2005 18:02:04 -0000 1.77
***************
*** 54,58 ****
import util.ioctl
import util.fthread
! import util.mediainfo
from event import *
--- 54,58 ----
import util.ioctl
import util.fthread
! import mediadb
from event import *
***************
*** 182,186 ****
media.item.display_type = parent.display_type
media.item.skin_display_type = parent.display_type
- media.item.create_metainfo()
m = media.item
--- 182,185 ----
***************
*** 374,378 ****
! def identify(self, media, force_rebuild=False):
"""
magic!
--- 373,377 ----
! def identify(self, media):
"""
magic!
***************
*** 429,434 ****
# if there is a disc, the tray can't be open
media.tray_open = False
! disc_info = util.fthread.call(util.mediainfo.disc_info, media,
! force_rebuild)
if not disc_info:
# bad disc, e.g. blank disc.
--- 428,433 ----
# if there is a disc, the tray can't be open
media.tray_open = False
! disc_info = util.fthread.call(mediadb.get, media)
!
if not disc_info:
# bad disc, e.g. blank disc.
***************
*** 436,443 ****
return
! data = disc_info.mmdata
# try to set the speed
! if config.ROM_SPEED and data and not data['mime'] == 'video/dvd':
try:
ioctl(fd, CDROM_SELECT_SPEED, config.ROM_SPEED)
--- 435,444 ----
return
! # FXIME:
! disc_info = disc_info
# try to set the speed
! if config.ROM_SPEED and disc_info and not \
! disc_info['mime'] == 'video/dvd':
try:
ioctl(fd, CDROM_SELECT_SPEED, config.ROM_SPEED)
***************
*** 445,451 ****
pass
! if data and data['mime'] == 'audio/cd':
os.close(fd)
! disc_id = data['id']
media.item = AudioDiskItem(disc_id, parent=None,
devicename=media.devicename,
--- 446,452 ----
pass
! if disc_info and disc_info['mime'] == 'audio/cd':
os.close(fd)
! disc_id = disc_info['id']
media.item = AudioDiskItem(disc_id, parent=None,
devicename=media.devicename,
***************
*** 453,458 ****
media.type = media.item.type
media.item.media = media
! if data['title']:
! media.item.name = data['title']
media.item.info = disc_info
return
--- 454,459 ----
media.type = media.item.type
media.item.media = media
! if disc_info['title']:
! media.item.name = disc_info['title']
media.item.info = disc_info
return
***************
*** 461,469 ****
image = title = movie_info = more_info = fxd_file = None
! media.id = data['id']
! media.label = data['label']
media.type = 'cdrom'
! label = data['label']
# is the id in the database?
--- 462,470 ----
image = title = movie_info = more_info = fxd_file = None
! media.id = disc_info['id']
! media.label = disc_info['label']
media.type = 'cdrom'
! label = disc_info['label']
# is the id in the database?
***************
*** 478,486 ****
# DVD/VCD/SVCD:
! # There is data from mmpython for these three types
! if data['mime'] in ('video/vcd', 'video/dvd'):
if not title:
title = media.label.replace('_', ' ').lstrip().rstrip()
! title = '%s [%s]' % (data['mime'][6:].upper(), title)
if movie_info:
--- 479,487 ----
# DVD/VCD/SVCD:
! # There is disc_info from mmpython for these three types
! if disc_info['mime'] in ('video/vcd', 'video/dvd'):
if not title:
title = media.label.replace('_', ' ').lstrip().rstrip()
! title = '%s [%s]' % (disc_info['mime'][6:].upper(), title)
if movie_info:
***************
*** 490,530 ****
f = os.path.join(config.OVERLAY_DIR, 'disc-set', media.id)
media.item.image = util.getimage(f)
! variables = media.item.info.variables
! media.item.info = disc_info
! media.item.info.set_variables(variables)
!
media.item.name = title
- media.item.set_url(data['mime'][6:] + '://')
media.item.media = media
!
! media.type = data['mime'][6:]
!
! media.item.info.mmdata = data
return
- # Disc is data of some sort. Mount it to get the file info
- util.mount(media.mountdir, force=True)
- if os.path.isdir(os.path.join(media.mountdir, 'VIDEO_TS')) or \
- os.path.isdir(os.path.join(media.mountdir, 'video_ts')):
- if force_rebuild:
- log.info('Double check without success')
- else:
- log.info('Undetected DVD, checking again')
- media.drive_status = CDS_NO_DISC
- util.umount(media.mountdir)
- return self.identify(media, True)
-
# Check for movies/audio/images on the disc
! num_video = disc_info['disc_num_video']
! num_audio = disc_info['disc_num_audio']
! num_image = disc_info['disc_num_image']
!
! video_files = util.match_files(media.mountdir, config.VIDEO_SUFFIX)
!
! log.debug('identifymedia: mplayer = "%s"' % video_files)
! media.item = DirItem(media.mountdir, None, create_metainfo=False)
media.item.info = disc_info
- util.umount(media.mountdir)
# if there is a video file on the root dir of the disc, we guess
--- 491,514 ----
f = os.path.join(config.OVERLAY_DIR, 'disc-set', media.id)
media.item.image = util.getimage(f)
! variables = media.item.info.get_variables()
media.item.name = title
media.item.media = media
! media.item.set_url(disc_info)
! media.item.info.set_variables(variables)
! media.type = disc_info['mime'][6:]
return
# Check for movies/audio/images on the disc
! video_files = util.find_matches(disc_info['listing'],
! config.VIDEO_SUFFIX)
! num_video = len(video_files)
! num_audio = len(util.find_matches(disc_info['listing'],
! config.AUDIO_SUFFIX))
! num_image = len(util.find_matches(disc_info['listing'],
! config.IMAGE_SUFFIX))
!
! media.item = DirItem(disc_info, None)
media.item.info = disc_info
# if there is a video file on the root dir of the disc, we guess
Index: mediamenu.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/plugins/mediamenu.py,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -d -r1.46 -r1.47
*** mediamenu.py 8 Jan 2005 15:40:53 -0000 1.46
--- mediamenu.py 10 Apr 2005 18:02:03 -0000 1.47
***************
*** 47,51 ****
from mainmenu import MainMenuItem
from menu import Menu
!
# get logging object
--- 47,52 ----
from mainmenu import MainMenuItem
from menu import Menu
! from mediadb import FileListing
! from gui import ProgressBox
# get logging object
***************
*** 84,98 ****
self.type = 'mediamenu'
!
! def main_menu_generate(self):
! """
! generate the items for the main menu. This is needed when first
! generating the menu and if something changes by pressing the EJECT
! button
! """
! items = copy.copy(self.normal_items)
!
if config.HIDE_UNUSABLE_DISCS:
! dir_types = {
'audio': [ 'dir', 'audiocd', 'audio', 'empty_cdrom' ],
'video': [ 'dir', 'video', 'vcd', 'dvd', 'empty_cdrom' ],
--- 85,92 ----
self.type = 'mediamenu'
! # init the style how to handle discs
if config.HIDE_UNUSABLE_DISCS:
! # set the disc types to be shown
! self.dir_types = {
'audio': [ 'dir', 'audiocd', 'audio', 'empty_cdrom' ],
'video': [ 'dir', 'video', 'vcd', 'dvd', 'empty_cdrom' ],
***************
*** 101,118 ****
}
else:
! dir_types = {}
for type in ('audio', 'video', 'image', 'games'):
! dir_types[type] = [ 'dir', 'audiocd', 'audio', 'video',
! 'vcd', 'dvd', 'empty_cdrom' ]
if self.display_type:
plugins_list = plugin.get('mainmenu_%s' % self.display_type)
else:
plugins_list = []
! dir_type = dir_types.get( self.display_type, [ ] )
for p in plugins_list:
-
if isinstance( p, plugins.rom_drives.rom_items ):
# do not show media from other menus
--- 95,126 ----
}
else:
! # show all discs in all mediamenus
! self.dir_types = {}
for type in ('audio', 'video', 'image', 'games'):
! self.dir_types[type] = [ 'dir', 'audiocd', 'audio', 'video',
! 'vcd', 'dvd', 'empty_cdrom' ]
!
!
! def main_menu_generate(self):
! """
! generate the items for the main menu. This is needed when first
! generating the menu and if something changes by pressing the EJECT
! button
! """
! # copy the "normal" items and add plugin data
! items = copy.copy(self.normal_items)
if self.display_type:
+ # get display type based plugins
plugins_list = plugin.get('mainmenu_%s' % self.display_type)
else:
+ # no plugins
plugins_list = []
! # get the dir_type
! dir_type = self.dir_types.get( self.display_type, [] )
+ # add all plugin data
for p in plugins_list:
if isinstance( p, plugins.rom_drives.rom_items ):
# do not show media from other menus
***************
*** 122,126 ****
else:
items += p.items( self )
-
return items
--- 130,133 ----
***************
*** 151,170 ****
items = []
! self.normal_items = []
# add default items
for item in items:
try:
add_args = None
if isstring(item):
title, filename = u'', item
else:
(title, filename) = item[:2]
if len(item) > 2:
add_args = item[2:]
reachable = 1
pos = filename.find(':/')
if pos > 0:
if filename.find(':/') < filename.find('/'):
hostname = filename[0:pos]
--- 158,184 ----
items = []
! files = []
! additional_data = {}
# add default items
for item in items:
try:
+ # split the list on dir/file, title and add_args
add_args = None
if isstring(item):
+ # only a filename is given
title, filename = u'', item
else:
+ # title and filename are given
(title, filename) = item[:2]
if len(item) > 2:
+ # ... and add_args
add_args = item[2:]
+ # is the dir / file reachable?
reachable = 1
pos = filename.find(':/')
if pos > 0:
+ # it is an url
if filename.find(':/') < filename.find('/'):
hostname = filename[0:pos]
***************
*** 174,207 ****
if os.system(alive) != 0:
reachable = 0
! except:
log.exception('Error parsing %s' % filename)
!
if reachable:
if vfs.isdir(filename):
! item = DirItem(String(filename), self,
! display_type=self.display_type,
! add_args=add_args)
! if title:
! item.name = title
! self.normal_items.append(item)
else:
! if not vfs.isfile(filename):
! if filename.startswith(os.getcwd()):
! filename = filename[len(os.getcwd()):]
! if filename[0] == '/':
! filename = filename[1:]
! filename = vfs.join(config.SHARE_DIR,
filename)
! # normal file
! for p in plugin.mimetype(self.display_type):
! items = p.get(self, [ String(filename) ])
! if title:
! for i in items:
! i.name = title
! self.normal_items += items
!
except:
log.exception('Error parsing %s' % str(item))
items = self.main_menu_generate()
--- 188,252 ----
if os.system(alive) != 0:
reachable = 0
! except Exception, e:
log.exception('Error parsing %s' % filename)
! raise e
if reachable:
if vfs.isdir(filename):
! # directory
! files.append(filename)
! additional_data[filename] = ( title, add_args, True )
else:
! if not vfs.isfile(filename) and \
! filename.startswith(os.getcwd()):
! # file is in share dir
! filename = filename[len(os.getcwd()):]
! if filename[0] == '/':
! filename = filename[1:]
! filename = vfs.join(config.SHARE_DIR, filename)
! # add files
! files.append(filename)
! additional_data[filename] = ( title, [], False )
except:
log.exception('Error parsing %s' % str(item))
+ # check and update the listing
+ listing = FileListing(files)
+ if listing.num_changes > 10:
+ text = _('Scanning menu, be patient...')
+ popup = ProgressBox(text, full=listing.num_changes)
+ popup.show()
+ listing.update(popup.tick)
+ popup.destroy()
+ elif listing.num_changes:
+ listing.update()
+
+ # Generate the media menu, we need to create a new listing (that
sucks)
+ # But with the listing we have, the order will be mixed up.
+ self.normal_items = []
+ for f in files:
+ listing = FileListing([f])
+ if listing.num_changes > 0:
+ # this shouldn't happen, but just in case
+ listing.update()
+ # get additional_data for the file
+ title, add_args, is_dir = additional_data[f]
+ if is_dir:
+ # directory
+ for item in listing.get_dir():
+ d = DirItem(item, self, name = title,
+ display_type = self.display_type,
+ add_args = add_args)
+ self.normal_items.append(d)
+ else:
+ # normal file
+ for p in plugin.mimetype(self.display_type):
+ items = p.get(self, listing)
+ if title:
+ for i in items:
+ i.name = title
+ self.normal_items += items
+
+ # generate all other items
items = self.main_menu_generate()
***************
*** 215,219 ****
reload_func = self.reload)
item_menu.skin_force_text_view = force_text_view
- self.menuw = menuw
menuw.pushmenu(item_menu)
--- 260,263 ----
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog