Exemple #1
0
    def __init__(self, heading, choices, fxd_file=None, umount_all=0, reload_func=None, item_types=None,
        force_skin_layout=-1):

        self.heading = heading
        self.choices = choices          # List of MenuItems
        if len(self.choices):
            self.selected = self.choices[0]
        else:
            self.selected = None
        self.page_start = 0
        self.previous_page_start = []
        self.previous_page_start.append(0)
        self.umount_all = umount_all    # umount all ROM drives on display?
        self.skin_settings = None
        if fxd_file:
            self.skin_settings = skin.load(fxd_file)

        # special items for the new skin to use in the view or info
        # area. If None, menu.selected will be taken
        self.infoitem = None
        self.viewitem = None

        # Called when a child menu returns. This function returns a new menu
        # or None and the old menu will be reused
        self.reload_func       = reload_func
        self.item_types        = item_types
        self.force_skin_layout = force_skin_layout
        self.display_style     = skin.get_display_style(self)

        # How many menus to go back when 'BACK_ONE_MENU' is called
        self.back_one_menu = 1
Exemple #2
0
    def __init__(self, heading, choices, fxd_file=None, umount_all=0, reload_func=None, item_types=None,
        force_skin_layout=-1):

        self.heading = heading
        self.choices = choices          # List of MenuItems
        if len(self.choices):
            self.selected = self.choices[0]
        else:
            self.selected = None
        self.page_start = 0
        self.previous_page_start = []
        self.previous_page_start.append(0)
        self.umount_all = umount_all    # umount all ROM drives on display?
        self.skin_settings = None
        if fxd_file:
            self.skin_settings = skin.load(fxd_file)

        # special items for the new skin to use in the view or info
        # area. If None, menu.selected will be taken
        self.infoitem = None
        self.viewitem = None

        # Called when a child menu returns. This function returns a new menu
        # or None and the old menu will be reused
        self.reload_func       = reload_func
        self.item_types        = item_types
        self.force_skin_layout = force_skin_layout
        self.display_style     = skin.get_display_style(self)

        # How many menus to go back when 'BACK_ONE_MENU' is called
        self.back_one_menu = 1
Exemple #3
0
    def __init__(self, menuw, movie):
        if movie is None:
            name = _('No Information Available')
            description = ''
        else:
            self.movie = movie
            name = movie['title']
            desc = movie['plot']

            if config.SKIN_HANDLES_DETAILS:
                # This is a skin that handles the details (like xbmc one) by itself.
                # We only provide the plot then and let the skin display what it wants.
                # The skin will handle all the rest.
                description = desc
            else:
                # OK, these are the simplistic skins that like all given on the plate
                # let's format the description with all info necessary.
                sub_title = movie['tagline']
                # gather the info and construct the description text
                if sub_title:
                    # subtitle + newline + description
                    description = u'"' + sub_title + u'"\n' + desc + u'\n\n'
                else:
                    # or just the description, if there is no subtitle
                    description = desc + u'\n\n'
                # add some additional info if they are available
                if movie['genre']:
                    description += _('Genre') + u' : ' + movie['genre'] + u'\n'
                if movie['length']:
                    description += _(
                        'Length') + u' : ' + movie['length'] + u'\n'
                if movie['year']:
                    description += _('Year') + u' : ' + movie['year'] + u'\n'
                if movie['rating']:
                    description += _(
                        'Rating') + u' : ' + movie['rating'] + u'\n'
                if movie['mpaa']:
                    description += _('MPAA') + u' : ' + movie['mpaa'] + u'\n'

        # that's all, we can show this to the user
        ScrollableTextScreen.__init__(self, 'tvguideinfo', description)
        self.name = name
        self.visible = True

        if movie.skin_fxd:
            self.skin_settings = skin.load(movie.skin_fxd)

        self.show(menuw)
Exemple #4
0
    def __init__(self, menuw, movie):
        if movie is None:
            name = _('No Information Available')
            description = ''
        else:
            self.movie = movie
            name = movie['title']
            desc = movie['plot']
            
            if config.SKIN_HANDLES_DETAILS:
                # This is a skin that handles the details (like xbmc one) by itself.
                # We only provide the plot then and let the skin display what it wants.
                # The skin will handle all the rest.
                description = desc
            else:
                # OK, these are the simplistic skins that like all given on the plate
                # let's format the description with all info necessary.
                sub_title = movie['tagline']
                # gather the info and construct the description text
                if sub_title:
                    # subtitle + newline + description
                    description = u'"' + sub_title + u'"\n' + desc + u'\n\n'
                else:
                    # or just the description, if there is no subtitle
                    description = desc + u'\n\n'
                # add some additional info if they are available
                if movie['genre']:
                    description += _('Genre') + u' : '+movie['genre'] + u'\n'
                if movie['length']:
                    description +=  _('Length')+ u' : '+movie['length'] + u'\n'
                if movie['year']:
                    description +=  _('Year')+u' : '+movie['year'] + u'\n'
                if movie['rating']:
                    description +=  _('Rating')+u' : '+movie['rating'] + u'\n'
                if movie['mpaa']:
                    description +=  _('MPAA')+u' : '+movie['mpaa'] + u'\n'

        # that's all, we can show this to the user
        ScrollableTextScreen.__init__(self, 'tvguideinfo', description)
        self.name    = name
        self.visible = True
        
        if movie.skin_fxd:
            self.skin_settings = skin.load(movie.skin_fxd)

        self.show(menuw)
Exemple #5
0
    def build(self, arg=None, menuw=None):
        """
        build the items for the directory
        """
        self.menuw = menuw
        self.playlist = []
        self.play_items = []
        self.dir_items = []
        self.pl_items = []

        if self.media:
            self.media.mount()

        if hasattr(self, '__dirwatcher_last_time__'):
            del self.__dirwatcher_last_time__

        if arg == 'update':
            if not self.menu.choices:
                selected_pos = -1
            else:
                # store the current selected item
                selected_id = self.menu.selected.id()
                selected_pos = self.menu.choices.index(self.menu.selected)
            if hasattr(self.menu, 'skin_default_has_description'):
                del self.menu.skin_default_has_description
            if hasattr(self.menu, 'skin_default_no_images'):
                del self.menu.skin_default_no_images
            if hasattr(self.menu, 'skin_force_text_view'):
                del self.menu.skin_force_text_view
        elif not os.path.exists(self.dir):
            AlertBox(text=_('Directory does not exist')).show()
            return

        display_type = self.display_type
        if self.display_type == 'tv':
            display_type = 'video'

        if arg and arg.startswith('playlist:'):
            if arg.endswith(':random'):
                Playlist(playlist=[(self.dir, 0)],
                         parent=self,
                         display_type=display_type,
                         random=True).play(menuw=menuw)
            elif arg.endswith(':recursive'):
                Playlist(playlist=[(self.dir, 1)],
                         parent=self,
                         display_type=display_type,
                         random=False).play(menuw=menuw)
            elif arg.endswith(':random_recursive'):
                Playlist(playlist=[(self.dir, 1)],
                         parent=self,
                         display_type=display_type,
                         random=True).play(menuw=menuw)
            return

        if config.OSD_BUSYICON_TIMER:
            osd.get_singleton().busyicon.wait(config.OSD_BUSYICON_TIMER[0])

        files = vfs.listdir(self.dir, include_overlay=True)
        num_changes = mediainfo.check_cache(self.dir)

        pop = None
        callback = None
        if skin.active():
            if (num_changes > 10) or (num_changes and self.media):
                if self.media:
                    pop = ProgressBox(text=_('Scanning disc, be patient...'),
                                      full=num_changes)
                else:
                    pop = ProgressBox(
                        text=_('Scanning directory, be patient...'),
                        full=num_changes)
                pop.show()
                callback = pop.tick

        elif config.OSD_BUSYICON_TIMER and len(
                files) > config.OSD_BUSYICON_TIMER[1]:
            # many files, just show the busy icon now
            osd.get_singleton().busyicon.wait(0)

        if num_changes > 0:
            mediainfo.cache_dir(self.dir, callback=callback)

        #
        # build items
        #
        # build play_items, pl_items and dir_items
        for p in plugin.mimetype(display_type):
            for i in p.get(self, files):
                if i.type == 'playlist':
                    self.pl_items.append(i)
                elif i.type == 'dir':
                    self.dir_items.append(i)
                else:
                    self.play_items.append(i)

        # normal DirItems
        for filename in files:
            if os.path.isdir(filename):
                d = DirItem(filename, self, display_type=self.display_type)
                self.dir_items.append(d)

        # remove same beginning from all play_items
        if self.DIRECTORY_SMART_NAMES:
            substr = ''
            if len(self.play_items) > 4 and len(self.play_items[0].name) > 5:
                substr = self.play_items[0].name[:-5].lower()
                for i in self.play_items[1:]:
                    if len(i.name) > 5:
                        substr = util.find_start_string(i.name.lower(), substr)
                        if not substr or len(substr) < 10:
                            break
                    else:
                        break
                else:
                    for i in self.play_items:
                        i.name = util.remove_start_string(i.name, substr)

        #
        # sort all items
        #

        # sort directories
        if self.DIRECTORY_SMART_SORT:
            self.dir_items.sort(lambda l, o: util.smartsort(l.dir, o.dir))
        else:
            self.dir_items.sort(lambda l, o: cmp(l.dir.upper(), o.dir.upper()))

        # sort playlist
        self.pl_items.sort(lambda l, o: cmp(l.name.upper(), o.name.upper()))

        # sort normal items
        if self.DIRECTORY_SORT_BY_DATE:
            self.play_items.sort(lambda l, o: cmp(
                l.sort('date').upper(),
                o.sort('date').upper()))
        elif self['%s_advanced_sort' % display_type]:
            self.play_items.sort(lambda l, o: cmp(
                l.sort('advanced').upper(),
                o.sort('advanced').upper()))
        else:
            self.play_items.sort(lambda l, o: cmp(l.sort().upper(),
                                                  o.sort().upper()))

        if self['num_dir_items'] != len(self.dir_items):
            self['num_dir_items'] = len(self.dir_items)

        if self['num_%s_items' %
                display_type] != len(self.play_items) + len(self.pl_items):
            self['num_%s_items' %
                 display_type] = len(self.play_items) + len(self.pl_items)

        if self.DIRECTORY_REVERSE_SORT:
            self.dir_items.reverse()
            self.play_items.reverse()
            self.pl_items.reverse()

        # delete pl_items if they should not be displayed
        if self.display_type and not self.display_type in self.DIRECTORY_ADD_PLAYLIST_FILES:
            self.pl_items = []

        # add all playable items to the playlist of the directory
        # to play one files after the other
        if not self.display_type or self.display_type in self.DIRECTORY_CREATE_PLAYLIST:
            self.playlist = self.play_items

        # build a list of all items
        items = self.dir_items + self.pl_items + self.play_items

        # random playlist (only active for audio)
        if self.display_type and self.display_type in self.DIRECTORY_ADD_RANDOM_PLAYLIST \
               and len(self.play_items) > 1:
            pl = Playlist(_('Random playlist'),
                          self.play_items,
                          self,
                          random=True)
            pl.autoplay = True
            items = [pl] + items

        if pop:
            pop.destroy()
            # closing the poup will rebuild the menu which may umount
            # the drive
            if self.media:
                self.media.mount()

        if config.OSD_BUSYICON_TIMER:
            # stop the timer. If the icons is drawn, it will stay there
            # until the osd is redrawn, if not, we don't need it to pop
            # up the next milliseconds
            osd.get_singleton().busyicon.stop()

        #
        # action
        #

        if arg == 'update':
            # update because of dirwatcher changes
            self.menu.choices = items

            if selected_pos != -1:
                for i in items:
                    if Unicode(i.id()) == Unicode(selected_id):
                        self.menu.selected = i
                        break
                else:
                    # item is gone now, try to the selection close
                    # to the old item
                    pos = max(0, min(selected_pos - 1, len(items) - 1))
                    if items:
                        self.menu.selected = items[pos]
                    else:
                        self.menu.selected = None
            if self.menuw:
                if self.menu.selected and selected_pos != -1:
                    self.menuw.rebuild_page()
                else:
                    self.menuw.init_page()
                self.menuw.refresh()


        elif len(items) == 1 and items[0].actions() and \
                 self.DIRECTORY_AUTOPLAY_SINGLE_ITEM:
            # autoplay
            items[0].actions()[0][0](menuw=menuw)

        elif arg == 'play' and self.play_items:
            # called by play function
            self.playlist = self.play_items
            Playlist.play(self, menuw=menuw)

        else:
            # normal menu build
            item_menu = menu.Menu(
                self.name,
                items,
                reload_func=self.reload,
                item_types=self.skin_display_type,
                force_skin_layout=self.DIRECTORY_FORCE_SKIN_LAYOUT)

            if self.skin_fxd:
                item_menu.skin_settings = skin.load(self.skin_fxd)

            menuw.pushmenu(item_menu)

            dirwatcher.cwd(menuw, self, item_menu, self.dir)
            self.menu = item_menu
            self.menuw = menuw
Exemple #6
0
    def set_url(self, url, info=True, search_image=True):
        """
        Set a new url to the item and adjust all attributes depending
        on the url.
        WARNING: This is called whenever self.url is set, therefor it is
        strictly forbidden to set self.url directly in this function,
        (infinit recursion!). Use self.__dict__['url'] instead!
        """
        # set the url itself
        if url and url.find('://') == -1:
            # local url
            self.__dict__['url'] = 'file://' + url
        else:
            # some other kind of url
            self.__dict__['url'] = url

        if self.url==None:
            # reset everything to default values
            self.network_play = True
            self.filename     = ''
            self.mode         = ''
            self.files        = None
            self.mimetype     = ''
            return

        # add additional info files
        self.files = FileInformation()
        if self.media:
            self.files.read_only = True

        # determine the mode of this item
        self.mode = self.url[:self.url.find('://')]

        if self.mode == 'file':
            self.network_play = False
            self.filename     = self.url[7:]
            self.files.append(self.filename)
            self.mimetype = os.path.splitext(self.filename)[1][1:].lower()
            basename      = self.filename[:self.filename.rfind('.')]

            if search_image:
                image = util.getimage(self.filename[:self.filename.rfind('.')])
                if image:
                    self.image = image
                    self.files.image = image
                elif self.parent and self.parent.type != 'dir':
                    imagepath= os.path.dirname(self.filename)
                    imagepath= os.path.join(imagepath, 'cover')
                    self.image = util.getimage(imagepath, self.image)
            # TODO: is this the right place for this?
            if config.TV_RECORD_REMOVE_COMMERCIALS:
                edlFile = basename + ".edl"
                self.edl_file = edlFile
                if os.path.exists(edlFile):
                    self.files.edl_file = edlFile
                else:
                    self.files.edl_file = None

            if info:
                self.info = mediainfo.get(self.filename)
                try:
                    if self.parent.DIRECTORY_USE_MEDIAID_TAG_NAMES:
                        self.name = self.info['title'] or self.name
                except:
                    pass
                if not self.name:
                    self.name = self.info['title:filename']

            if not self.name:
                self.name = util.getname(self.filename)

            if config.SKIN_LOAD_FXD_FOR_ITEMS:
                self.skin_fxd = util.getskinfxd(self.filename)
                if self.skin_fxd:
                    self.skin_settings = skin.load(self.skin_fxd, False)

        else:
            # some defaults for other url types
            self.network_play = True
            self.filename     = ''
            self.mimetype     = self.type
            if not self.name:
                self.name     = Unicode(self.url)
Exemple #7
0
    def set_url(self, url, info=True, search_image=True):
        """
        Set a new url to the item and adjust all attributes depending
        on the url.
        WARNING: This is called whenever self.url is set, therefor it is
        strictly forbidden to set self.url directly in this function,
        (infinit recursion!). Use self.__dict__['url'] instead!
        """
        # set the url itself
        if url and url.find('://') == -1:
            # local url
            self.__dict__['url'] = 'file://' + url
        else:
            # some other kind of url
            self.__dict__['url'] = url

        if self.url == None:
            # reset everything to default values
            self.network_play = True
            self.filename = ''
            self.mode = ''
            self.files = None
            self.mimetype = ''
            return

        # add additional info files
        self.files = FileInformation()
        if self.media:
            self.files.read_only = True

        # determine the mode of this item
        self.mode = self.url[:self.url.find('://')]

        if self.mode == 'file':
            self.network_play = False
            self.filename = self.url[7:]
            self.files.append(self.filename)
            self.mimetype = os.path.splitext(self.filename)[1][1:].lower()
            basename = self.filename[:self.filename.rfind('.')]

            if search_image:
                image = util.getimage(self.filename[:self.filename.rfind('.')])
                if image:
                    self.image = image
                    self.files.image = image
                elif self.parent and self.parent.type != 'dir':
                    imagepath = os.path.dirname(self.filename)
                    imagepath = os.path.join(imagepath, 'cover')
                    self.image = util.getimage(imagepath, self.image)
            # TODO: is this the right place for this?
            if config.TV_RECORD_REMOVE_COMMERCIALS:
                edlFile = basename + ".edl"
                self.edl_file = edlFile
                if os.path.exists(edlFile):
                    self.files.edl_file = edlFile
                else:
                    self.files.edl_file = None

            if info:
                self.info = mediainfo.get(self.filename)
                try:
                    if self.parent.DIRECTORY_USE_MEDIAID_TAG_NAMES:
                        self.name = self.info['title'] or self.name
                except:
                    pass
                if not self.name:
                    self.name = self.info['title:filename']

            if not self.name:
                self.name = util.getname(self.filename)

            if config.SKIN_LOAD_FXD_FOR_ITEMS:
                self.skin_fxd = util.getskinfxd(self.filename)
                if self.skin_fxd:
                    self.skin_settings = skin.load(self.skin_fxd, False)

        else:
            # some defaults for other url types
            self.network_play = True
            self.filename = ''
            self.mimetype = self.type
            if not self.name:
                self.name = Unicode(self.url)
Exemple #8
0
 def set_skin_fxd(self, item):
     """
     return the number of items per page for this skin
     """
     if hasattr(item, 'skin_fxd') and item.skin_fxd:
         self.skin_settings = skin.load(item.skin_fxd)