Esempio n. 1
0
    def __ls_menu(self, cb, *args):

        for name, category in [("Search", "video"),
                               ("Recently Featured", "recently_featured"),
                               ("Today's Top Rated", "top_rated"),
                               ("Most Viewed", "most_viewed"),
                               ("Most Popular", "most_popular"),
                               ("Music", "music"), ("Movies", "movie"),
                               ("News", "news"),
                               ("For Mobile Phones", "watch_on_mobile")]:
            item = File(self)
            query = ""
            idx = 0
            item.path = File.pack_path("/search", name, category, query, idx)
            item.resource = item.path
            item.name = name
            item.mimetype = File.DIRECTORY
            item.folder_flags = File.ITEMS_UNSORTED
            if (name in _ICONS):
                item.icon = _ICONS[name].get_path()

            cb(item, *args)
        #end for

        cb(None, *args)
Esempio n. 2
0
    def get_file(self, path):

        parts = File.unpack_path(path)
        prefix = parts[0]

        f = None
        if (prefix == "/"):
            # root folder
            f = File(self)
            f.is_local = True
            f.path = "/"
            f.mimetype = f.DIRECTORY
            f.resource = ""
            f.name = self.get_name()
            f.info = "Browse your music library by album"
            f.icon = self.get_icon().get_path()
            f.folder_flags = f.ITEMS_ENQUEUEABLE | f.ITEMS_COMPACT

        elif (prefix == "/albums"):
            # album
            ffolder, album = parts[1:]
            f = self.__make_album(ffolder, album)

        elif (prefix == "/tracks"):
            # track
            artist, album, title, trackno, resource, mimetype = parts[1:]
            f = self.__make_track(artist, album, title, trackno, resource,
                                  mimetype)

        return f
Esempio n. 3
0
    def get_file(self, path):

        parts = [p for p in path.split("/") if p]
        len_parts = len(parts)

        f = None
        if (len_parts == 0):
            f = File(self)
            f.name = self.get_name()
            f.info = "Change the configuration"
            f.path = "/"
            f.icon = self.get_icon().get_path()
            f.mimetype = f.DEVICE_ROOT
            f.folder_flags = f.ITEMS_COMPACT

        elif (len_parts == 1):
            cfg_name = parts[-1]
            cs = [c for c in self.__configurators if ` c ` == cfg_name]
            if (cs):
                c = cs[0]
                f = self.__make_configurator(c)
            #end if
        #end if

        return f
Esempio n. 4
0
        def on_receive_node(node):
            if (node.get_name() == "{%s}totalResults" % _XMLNS_OPENSEARCH):
                # read total number of hits
                total_results = int(node.get_pcdata())

                # set a sane limit (YouTube cannot handle more anyway)
                total_results = min(total_results, 20 * _PAGE_SIZE)

                page = 1
                for n in range(1, total_results, _PAGE_SIZE):
                    f = File(self)
                    f.name = "Page %d" % page
                    f.path = File.pack_path("/search", f.name, category, query,
                                            n)
                    f.mimetype = f.DIRECTORY
                    f.info = "Results %d - %d" % (
                        n, min(total_results, n + _PAGE_SIZE - 1))
                    f.folder_flags = File.ITEMS_UNSORTED
                    cb(f, *args)
                    page += 1
                #end for

                cb(None, *args)

            return True
Esempio n. 5
0
    def get_file(self, path):

        parts = [ p for p in path.split("/") if p ]
        len_parts = len(parts)
        
        f = None
        if (len_parts == 0):
            # root folder
            f = File(self)
            f.path = "/"
            f.mimetype = f.DIRECTORY
            f.resource = ""
            f.name = self.get_name()
            f.info = "Browse the SHOUTcast directory"
            f.icon = self.get_icon().get_path()
            f.folder_flags = f.ITEMS_ENQUEUEABLE | f.ITEMS_COMPACT
    
        elif (len_parts == 1):
            genre = urlquote.unquote(parts[0])
            f = self.__make_genre(genre)
    
        elif (len_parts == 2):
            f = self.__make_station(parts[1])

        return f
Esempio n. 6
0
    def __make_genre(self, genre):

        f = File(self)    
        f.name = genre
        f.path = "/" + urlquote.quote(genre, "")
        f.mimetype = f.DIRECTORY
        f.icon = theme.shoutcast_folder.get_path()
        f.folder_flags = f.ITEMS_ENQUEUEABLE

        return f
Esempio n. 7
0
    def get_root(self):

        f = File(self)
        f.name = self.get_name()
        f.path = "/"
        f.mimetype = f.DEVICE_ROOT
        f.folder_flags = f.ITEMS_ADDABLE  #| f.ITEMS_COMPACT
        f.icon = self.get_icon().get_path()

        return f
Esempio n. 8
0
    def __make_genre(self, genre, href):

        f = File(self)
        f.name = genre
        f.path = href
        f.mimetype = f.DIRECTORY
        f.icon = theme.icecast_folder.get_path()
        f.folder_flags = f.ITEMS_ENQUEUEABLE

        return f
Esempio n. 9
0
    def __make_genre(self, genre):

        f = File(self)
        f.path = File.pack_path("/genres", genre)
        f.name = genre
        f.acoustic_name = genre
        f.mimetype = f.DIRECTORY
        f.icon = theme.mb_folder_genre.get_path()
        f.folder_flags = f.ITEMS_ENQUEUEABLE | \
                         f.ITEMS_COMPACT
        return f
Esempio n. 10
0
 def __make_artist(self, artist):
 
     f = File(self)
     f.path = File.pack_path("/artists", artist)
     f.name = artist
     f.acoustic_name = f.name
     f.mimetype = f.DIRECTORY
     f.icon = theme.mb_folder_artist.get_path()
     f.folder_flags = f.ITEMS_ENQUEUEABLE | \
                         f.ITEMS_COMPACT
     return f
Esempio n. 11
0
    def get_file(self, path):
    
        f = None
        if (path == "/"):
            f = File(self)
            f.path = "0"
            f.mimetype = f.DEVICE_ROOT
            f.resource = ""
            f.name = self.get_name()
            f.icon = self.get_icon()
            f.info = "UPnP network storage"
            f.folder_flags = f.ITEMS_ENQUEUEABLE
            
        else:
            if (path.startswith("/")): path = path[1:]
            didl, nil, nil, nil = self.__cds_proxy.Browse(None, path,
                                                          "BrowseMetadata",
                                                          "*", "0", "0", "")
            entry = didl_lite.parse(didl)
            ident, clss, child_count, res, title, artist, mimetype = entry[0]

            url_base = self.__description.get_url_base()

            f = File(self)
            f.mimetype = mimetype
            f.resource = res
            f.name = title
            f.info = artist
            f.path = "/" + path

            if (f.mimetype == f.DIRECTORY):
                f.resource = ident
                f.folder_flags = f.ITEMS_ENQUEUEABLE
            else:
                f.resource = urlparse.urljoin(url_base, res)
            f.child_count = child_count

        return f
Esempio n. 12
0
    def get_root(self):

        f = File(self)
        f.path = "/"
        f.mimetype = f.DIRECTORY
        f.resource = ""
        f.name = self.get_name()
        f.info = "Editable list of radio stations"
        f.icon = self.get_icon()
        f.folder_flags = f.ITEMS_ENQUEUEABLE | \
                         f.ITEMS_ADDABLE | \
                         f.ITEMS_DELETABLE

        return f
Esempio n. 13
0
    def __make_folder(self, folder_name):

        f = File(self)
        f.is_local = True
        f.path = "/" + urlquote.quote(folder_name, "")
        f.mimetype = "application/x-image-folder"
        f.resource = ""
        f.name = folder_name
        f.acoustic_name = "Folder: " + f.name
        #f.info = "%d items" % len(self.__folders.get(folder_name, []))
        f.folder_flags = f.ITEMS_ENQUEUEABLE | \
                            f.ITEMS_COMPACT

        return f
Esempio n. 14
0
    def __make_folder(self, folder_name):

        f = File(self)
        f.is_local = True
        f.path = "/" + urlquote.quote(folder_name, "")
        f.mimetype = f.DIRECTORY
        f.resource = ""
        f.name = folder_name
        f.acoustic_name = "Folder: " + f.name
        f.icon = theme.mb_folder_audioclips.get_path()
        #f.info = "%d items" % len(self.__folders.get(folder_name, []))
        f.folder_flags = f.ITEMS_ENQUEUEABLE

        return f
Esempio n. 15
0
    def __make_folder(self, month, year):

        f = File(self)
        f.is_local = True
        f.path = File.pack_path("/months", str(month), str(year))
        f.mimetype = "application/x-image-folder"
        f.resource = ""
        f.name = "%s %d" % (_MONTHS[month - 1], year)
        f.acoustic_name = "Folder: " + f.name
        f.comparable = 0 - ((year * 100) + month)
        #f.info = "%d items" % len(self.__folders.get(folder_name, []))
        f.folder_flags = f.ITEMS_ENQUEUEABLE | \
                            f.ITEMS_COMPACT

        return f
Esempio n. 16
0
    def __make_album(self, ffolder, album):

        f = File(self)
        f.is_local = True
        f.path = File.pack_path("/albums", ffolder, album)
        f.name = album
        f.acoustic_name = f.name
        #f.info = artist
        f.mimetype = "application/x-music-folder"
        f.folder_flags = f.ITEMS_ENQUEUEABLE
        f.comparable = f.name

        if (album == "All Tracks"):
            f.icon = theme.mb_folder_audio.get_path()

        return f
Esempio n. 17
0
 def get_file(self, path):
 
     f = None
     if (path == "/"):
         f = File(self)
         f.name = "Internet Radio"
         f.info = "Listen to Internet Radio"
         f.path = "/"
         f.mimetype = File.DEVICE_ROOT
         f.icon = self.get_icon().get_path()
         f.folder_flags = File.ITEMS_ADDABLE | File.ITEMS_SORTABLE
         
     else:
         prefix, name, url = File.unpack_path(path)
         f = self.__make_station(name, url)
         
     return f
Esempio n. 18
0
    def get_file(self, path):

        f = None
        if (path == "/"):
            f = File(self)
            f.name = self.get_name()
            f.path = "/"
            f.mimetype = f.DEVICE_ROOT
            f.folder_flags = f.ITEMS_COMPACT

        else:
            for c in self.__list_categories():
                if (c.path == path):
                    f = c
                    break
            #end for
        #end if

        return f
Esempio n. 19
0
    def get_file(self, path):

        parts = [p for p in path.split("/") if p]
        len_parts = len(parts)

        f = None
        if (len_parts == 0):
            f = File(self)
            f.is_local = True
            f.path = "/"
            f.mimetype = f.DEVICE_ROOT
            f.resource = ""
            f.name = self.get_name()
            f.info = "Browse your video library"
            f.icon = self.get_icon().get_path()
            f.folder_flags = f.ITEMS_ENQUEUEABLE  #| f.ITEMS_COMPACT

        elif (len_parts == 1):
            folder_name = urlquote.unquote(parts[0])
            f = self.__make_folder(folder_name)

        return f
Esempio n. 20
0
    def __list_categories(self):

        out = []
        for name, info, path, icon in [
            ("Music", "Browse Music Library", "/audio", theme.mb_folder_audio),
            ("Videos", "Browse Video Library", "/video",
             theme.mb_folder_video),
            ("Pictures", "Browse Picture Library", "/image",
             theme.mb_folder_image),
            ("Storage & Network", "Browse storage and network", "/storage",
             theme.mb_folder_storage),
        ]:
            f = File(self)
            f.name = name
            f.info = info
            f.path = path
            f.mimetype = f.DIRECTORY
            f.icon = icon.get_path()
            f.folder_flags = f.ITEMS_COMPACT
            out.append(f)
        #end for

        return out
Esempio n. 21
0
    def get_file(self, path):

        parts = File.unpack_path(path)
        prefix = parts[0]

        f = None
        if (prefix == "/"):
            f = File(self)
            f.is_local = True
            f.path = "/"
            f.mimetype = f.DEVICE_ROOT
            f.resource = ""
            f.name = self.get_name()
            f.info = "Browse your camera pictures"
            f.icon = self.get_icon().get_path()
            f.folder_flags = f.ITEMS_ENQUEUEABLE | f.ITEMS_COMPACT

        elif (prefix == "/months"):
            month, year = parts[1:]
            month = int(month)
            year = int(year)
            f = self.__make_folder(month, year)

        return f
Esempio n. 22
0
    def __build_file(self, url_base, entry):

        ident, clss, child_count, res, title, artist, mimetype = entry
        f = File(self)
        f.mimetype = mimetype
        f.resource = res or urlparse.urljoin(url_base, ident)
        f.name = title
        f.artist = artist
        f.info = artist

        if (f.mimetype == f.DIRECTORY):
            f.path = "/" + ident
            f.folder_flags = f.ITEMS_ENQUEUEABLE
        else:
            f.path = "/" + ident

        f.child_count = child_count    
        
        # MythTV thinks Ogg-Vorbis was text/plain...
        if (clss.startswith("object.item.audioItem") and
            f.mimetype == "text/plain"):
            f.mimetype = "audio/x-unknown"

        # no useful MIME type reported? let's look at the file extension
        if (not f.mimetype in mimetypes.get_audio_types() + 
                              mimetypes.get_video_types() +
                              mimetypes.get_image_types() + [f.DIRECTORY]):
            ext = os.path.splitext(f.name)[-1]
            f.mimetype = mimetypes.ext_to_mimetype(ext)

        if (f.mimetype.startswith("image/")):
            f.thumbnail = f.resource
            
        logging.debug("'%s' has MIME type '%s'" % (f.name, f.mimetype))
        
        return f