Exemplo n.º 1
0
    def bookmark_menu(self, arg=None, menuw=None):
        """
        Bookmark list
        """
        bookmarkfile = util.get_bookmarkfile(self.item.filename)
        items = []
        for line in util.readfile(bookmarkfile):
            file = copy.copy(self.item)
            file.info = {}

            sec = int(line)
            hour = int(sec / 3600)
            min = int((sec - (hour * 3600)) / 60)
            sec = int(sec % 60)
            time = '%0.2d:%0.2d:%0.2d' % (hour, min, sec)
            # set a new title
            file.name = Unicode(_('Jump to %s') % (time))
            if hasattr(file, 'tv_show'):
                del file.tv_show

            if not self.item.mplayer_options:
                self.item.mplayer_options = ''
            file.mplayer_options = str(
                self.item.mplayer_options) + ' -ss %s' % time
            items.append(file)

        if items:
            moviemenu = menu.Menu(self.item.name,
                                  items,
                                  fxd_file=self.item.skin_fxd)
            menuw.pushmenu(moviemenu)
        return
Exemplo n.º 2
0
    def actions(self, item):
        self.item = item
        items = []
        if item['autobookmark_resume']:
            items.append((self.resume, _('Resume playback')))
        if item.type == 'dir' or item.type == 'playlist':
            return items
        if item.mode == 'file' and not item.variants and \
               not item.subitems and os.path.exists(util.get_bookmarkfile(item.filename)):
            items.append((self.bookmark_menu, _('Bookmarks')))

        return items
Exemplo n.º 3
0
 def __delete_do(self):
     bookmarkfile = util.get_bookmarkfile(self.item.filename)
     handle = open(bookmarkfile)
     bookmarks = ''
     for line in handle:
         if int(line) != self.time:
             bookmarks += line
     handle.close()
     handle = open(bookmarkfile, 'w')
     handle.write(bookmarks)
     handle.close()
     self.menuw.back_one_menu()
Exemplo n.º 4
0
    def actions(self, item):
        self.item = item
        items = []
        if item['autobookmark_resume']:
            items.append((self.resume, _('Resume playback')))
        if item.type == 'dir' or item.type == 'playlist':
            return items
        if hasattr(item, 'mode'):
            if item.mode == 'file' and not item.variants and \
                   not item.subitems and os.path.exists(util.get_bookmarkfile(item.filename)):
                items.append(( self.bookmark_menu, _('Bookmarks')))

        return items
Exemplo n.º 5
0
    def bookmark_menu(self,arg=None, menuw=None):
        """
        Bookmark list
        """
        bookmarkfile = util.get_bookmarkfile(self.item.filename)
        items = []
        for line in util.readfile(bookmarkfile):
            item = BookmarkItem(self.item, int(line))
            items.append(item)

        if items:
            item = menu.MenuItem(name=_('Clear all Bookmarks'), action=self.__clear_bookmarks, arg=self.item)
            items.append(item)
            moviemenu = menu.Menu(self.item.name, items, fxd_file=self.item.skin_fxd)
            menuw.pushmenu(moviemenu)
        return
Exemplo n.º 6
0
 def _select_time(self, arg=None, menuw=None, which=None):
     bookmarkfile = util.get_bookmarkfile(self.item.filename)
     if not os.path.exists(bookmarkfile):
         self.error(_('No bookmarks are set for this video'))
         return
     menu_items = []
     menu_items = [ menu.MenuItem(_('Do not set'), action=which, arg=None),]
     for line in util.readfile(bookmarkfile):
         sec = int(line)
         hour = int(sec/3600)
         min = int((sec-(hour*3600))/60)
         time = '%0.2d:%0.2d:%0.2d' % (hour,min,sec % 60)
         menu_items.append(menu.MenuItem(time, action=which, arg=sec))
     encoding_menu = menu.Menu(_('Select Time'), menu_items, item_types = 'video encoding menu')
     encoding_menu.infoitem = self
     menuw.pushmenu(encoding_menu)
     menuw.refresh()
Exemplo n.º 7
0
 def _select_time(self, arg=None, menuw=None, which=None):
     bookmarkfile = util.get_bookmarkfile(self.item.filename)
     if not os.path.exists(bookmarkfile):
         self.error(_('No bookmarks are set for this video'))
         return
     menu_items = []
     menu_items = [
         menu.MenuItem(_('Do not set'), action=which, arg=None),
     ]
     for line in util.readfile(bookmarkfile):
         sec = int(line)
         hour = int(sec / 3600)
         min = int((sec - (hour * 3600)) / 60)
         time = '%0.2d:%0.2d:%0.2d' % (hour, min, sec % 60)
         menu_items.append(menu.MenuItem(time, action=which, arg=sec))
     encoding_menu = menu.Menu(_('Select Time'),
                               menu_items,
                               item_types='video encoding menu')
     encoding_menu.infoitem = self
     menuw.pushmenu(encoding_menu)
     menuw.refresh()
Exemplo n.º 8
0
    def eventhandler(self, item, event, menuw):
        if event in (STOP, USER_END):
            playlist_remove = ("%s/playlist_xine*.tox" %
                               config.FREEVO_CACHEDIR)
            for filename in glob.glob(playlist_remove):
                os.remove(filename)
            if item.mode == 'file' and not item.variants and \
                not item.subitems and item.elapsed:
                item.store_info('autobookmark_resume', item.elapsed)
            else:
                _debug_('auto-bookmark not supported for this item')

        if event == PLAY_END:
            item.delete_info('autobookmark_resume')

        # Bookmark the current time into a file
        if event == STORE_BOOKMARK:
            #Get time elapsed for xine video
            videoplayer = self.item.player.name
            if (videoplayer == 'xine'):
                command = ("%s -S get_time" % config.CONF.xine)
                handle = os.popen(command, 'r')
                position = handle.read()
                handle.close()
                try:
                    item.elapsed = int(position)
                except ValueError, e:
                    _debug_('Cannot save bookmark for postion %r: %s' %
                            (position, e))
                    return False

            bookmarkfile = util.get_bookmarkfile(item.filename)

            handle = open(bookmarkfile, 'a+')
            handle.write(str(item.elapsed))
            handle.write('\n')
            handle.close()
            rc.post_event(Event(OSD_MESSAGE, arg='Added Bookmark'))
            return True
Exemplo n.º 9
0
    def eventhandler(self, item, event, menuw):
        if event in (STOP, USER_END):
            if item.mode == 'file' and not item.variants and \
                   not item.subitems and item.elapsed:
                item.store_info('autobookmark_resume', item.elapsed)
            else:
                _debug_('auto-bookmark not supported for this item')

        if event == PLAY_END:
            item.delete_info('autobookmark_resume')

        # Bookmark the current time into a file
        if event == STORE_BOOKMARK:
            bookmarkfile = util.get_bookmarkfile(item.filename)

            handle = open(bookmarkfile, 'a+')
            handle.write(str(item.elapsed))
            handle.write('\n')
            handle.close()
            rc.post_event(Event(OSD_MESSAGE, arg='Added Bookmark'))
            return True

        return False
Exemplo n.º 10
0
    def eventhandler(self, item, event, menuw):
        if event in (STOP, USER_END):
            if item.mode == 'file' and not item.variants and \
                not item.subitems and item.elapsed:
                item.store_info('autobookmark_resume', item.elapsed)
            else:
                logger.debug('auto-bookmark not supported for this item')

        if event == PLAY_END:
            item.delete_info('autobookmark_resume')

        # Bookmark the current time into a file
        if event == STORE_BOOKMARK:
            bookmarkfile = util.get_bookmarkfile(item.filename)

            handle = open(bookmarkfile,'a+')
            handle.write(str(item.elapsed))
            handle.write('\n')
            handle.close()
            rc.post_event(Event(OSD_MESSAGE, arg='Added Bookmark'))
            return True

        return False
Exemplo n.º 11
0
 def __clear_bookmarks_do(self):
     bookmarkfile = util.get_bookmarkfile(self.item.filename)
     os.remove(bookmarkfile)
     menuw.back_one_menu()