Beispiel #1
0
    def get_file(self, path):

        f = None
        if (path == "/"):
            f = File(self)
            f.path = "/"
            f.name = "YouTube"
            f.mimetype = f.DIRECTORY
            f.resource = ""
            f.info = "Browse and download videos from YouTube"
            f.icon = theme.youtube_folder.get_path()

        elif (path.startswith("/search")):
            nil, name, category, query, idx = File.unpack_path(path)
            f = File(self)
            f.name = name
            f.mimetype = f.DIRECTORY
            f.path = path
            f.resource = ""
            if (name in _ICONS):
                f.icon = _ICONS[name].get_path()

        elif (path.startswith("/videos")):
            f = self.__make_video(path)

        return f
Beispiel #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
Beispiel #3
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)
Beispiel #4
0
    def get_root(self):

        f = File(self)
        f.name = self.get_name()
        f.path = "/"
        f.mimetype = f.DIRECTORY
        return f
Beispiel #5
0
 def __parse_link(self, parent_path, node_nr, node):
 
     try:
         name = node.get_attr("title")
         url = node.get_attr("url")
         category = node.get_attr("category")
     except:
         return None
 
     if (name in _BLACKLISTED):
         return None
 
     if (not url.strip()):
         return None
     elif (url.endswith(".xml")):
         return None
   
     f = File(self)
     f.name = name
     f.resource = url
     f.path = File.pack_path(parent_path, `node_nr`, name, url)
     f.mimetype = "video/x-unknown"
     f.thumbnail = theme.worldtv_device.get_path()
     
     return f
Beispiel #6
0
 def get_file(self, path):
 
     f = File(self)
     f.path = path
     f.mimetype = "video/x-unknown"
     
     return f
Beispiel #7
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
Beispiel #8
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
Beispiel #9
0
    def __ls_playlists(self, begin_at, end_at, cb, *args):

        self.__lists.sort(lambda a, b: cmp(a[0], b[0]))
        playlists = [pl for n, pl in self.__lists]
        if (end_at == 0):
            playlists = playlists[begin_at:]
        else:
            playlists = playlists[begin_at:end_at]

        for pl in playlists:
            f = File(self)
            f.name = pl.get_name()
            #f.info = "%d items" % pl.get_size()
            f.path = "/" + urlquote.quote(f.name)
            f.mimetype = f.DIRECTORY
            f.icon = theme.mb_folder_playlist.get_path()
            f.folder_flags |= f.ITEMS_UNSORTED

            if (pl.get_name() != _PLAYLIST_RECENT_50):
                f.folder_flags |= f.ITEMS_SORTABLE

            cb(f, *args)
        #end for

        cb(None, *args)
Beispiel #10
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
Beispiel #11
0
    def get_file(self, path):

        if (self.__needs_playlist_reload):
            self.__load_playlists()
            self.__needs_playlist_reload = False

        if (path == "/"):
            return self.get_root()

        name = urlquote.unquote(path[1:])
        pl = self.__lookup_playlist(name)

        if (pl):
            f = File(self)
            f.name = pl.get_name()
            #f.info = "%d items" % pl.get_size()
            f.path = path
            f.mimetype = f.DIRECTORY
            f.icon = theme.mb_folder_playlist.get_path()

            if (pl.get_name() != _PLAYLIST_RECENT_50):
                f.folder_flags |= f.ITEMS_SORTABLE
            return f
        else:
            return None
Beispiel #12
0
    def new_file(self, path):

        # present search dialog
        dlg = Dialog()
        dlg.add_entry("Name:", "")
        dlg.add_entry("Location:", "http://")
        values = dlg.wait_for_values()

        if (values):
            name, location = values
            stations = inetstations.get_stations()
            stations.append((location, name))
            inetstations.save_stations(stations)

            item = File(self)
            item.path = self.__encode_path(name, location)
            item.resource = location
            item.name = name
            item.info = location
            if (location.endswith(".ram") or location.endswith(".rm")):
                item.mimetype = "application/vnd.rn-realmedia"
            else:
                item.mimetype = "audio/x-unknown"

            self.emit_message(msgs.CORE_EV_FOLDER_INVALIDATED, self.get_root())
            return item

        else:
            return None
Beispiel #13
0
    def __load_dvd(self, label, path):

        f = File(self.__device)
        f.path = "/"
        f.name = label
        f.mimetype = "video/x-dvd-image"
        f.resource = "dvd://%s" % path
        self.emit_message(msgs.MEDIA_ACT_LOAD, f)
        self.call_service(msgs.NOTIFY_SVC_SHOW_INFO, u"DVD inserted")
Beispiel #14
0
    def get_root(self):

        f = File(self)
        f.path = "/"
        f.name = self.__name
        f.mimetype = "video/x-vcd-image"
        f.resource = "vcd://dev/cdrom@P1"  # % self.__path

        return f
Beispiel #15
0
    def get_root(self):

        f = File(self)
        f.name = self.get_name()
        f.info = "History of recently visited folders"
        f.path = "/"
        f.mimetype = f.DEVICE_ROOT

        return f
Beispiel #16
0
    def __load_vcd(self, label):

        f = File(self.__device)
        f.path = "/"
        f.name = label
        f.mimetype = "video/x-vcd-image"
        f.resource = "vcd://dev/cdrom@P1"
        self.emit_message(msgs.MEDIA_ACT_LOAD, f)
        self.call_service(msgs.NOTIFY_SVC_SHOW_INFO, u"Video CD inserted")
Beispiel #17
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
Beispiel #18
0
 def get_root(self):
 
     f = File(self)
     f.path = "/"
     f.name = "World TV"
     f.mimetype = f.DIRECTORY
     f.resource = ""
     f.info = "Watch TV streams from all over the world"
     
     return f
Beispiel #19
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
Beispiel #20
0
 def get_root(self):
 
     f = File(self)
     f.path = "/"
     f.name = self.get_name()
     f.mimetype = f.DIRECTORY
     f.resource = ""
     f.info = "Listen to internet radio stations"
     
     return f
Beispiel #21
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
Beispiel #22
0
    def get_file(self, path):
            
        if (path == "/"):
            f = File(self)
            f.path = "/"
            f.name = "World TV"
            f.mimetype = f.DIRECTORY
            f.resource = ""
            f.info = "Watch TV streams from all over the world"
            f.icon = theme.worldtv_device.get_path()
        else:
            prefix, node_nr, name, url = File.unpack_path(path)
            f = File(self)
            f.name = name
            f.resource = url
            f.path = path
            f.mimetype = "video/x-unknown"

        return f
Beispiel #23
0
    def __make_configurator(self, c):

        f = File(self)
        f.name = c.TITLE
        f.info = c.DESCRIPTION
        f.resource = ` c `
        f.path = "/" + f.resource
        f.mimetype = f.CONFIGURATOR
        f.icon = c.ICON.get_path()

        return f
 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
Beispiel #25
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
Beispiel #26
0
    def get_file(self, path):

        prefix, path, mimetype = File.unpack_path(path)

        f = File(self)
        f.name = path
        f.path = path
        f.resource = path
        f.mimetype = mimetype

        return f
Beispiel #27
0
    def __parse_stations(self, data, genre):
        """
        Parses the list of stations.
        """

        stations = []
        soup = BeautifulSoup(data)
        resulttable = soup.find("div", {"id": "resulttable"})
        if (resulttable):
            for entry in resulttable.findAll("div", {"class": "dirlist"}):
                #print entry
                station = File(self)
                a_tag = entry.find("a", {"class": "playbutton playimage"})
                playing_tag = entry.find("div", {"class": "playingtext"})
                bitrate_tag = entry.find("div", {"class": "dirbitrate"})
                type_tag = entry.find("div", {"class": "dirtype"})

                if (not a_tag or not playing_tag or not bitrate_tag
                        or not type_tag):
                    continue

                station.resource = a_tag["href"]
                station.name = a_tag["title"]
                now_playing = playing_tag["title"]
                bitrate = bitrate_tag.contents[0].strip()

                typename = type_tag.contents[0].strip()
                if (typename == "MP3"):
                    station.mimetype = "audio/mpeg"
                elif (typename == "AAC+"):
                    station.mimetype = "audio/mp4"
                else:
                    station.mimetype = "audio/x-unknown"

                station.path = File.pack_path("/" + urlquote.quote(genre, ""),
                                              station.name, bitrate,
                                              station.mimetype,
                                              station.resource, genre)
                station.info = "Bitrate: %s kb\n" \
                               "Now playing: %s" % (bitrate, now_playing)
                station.icon = theme.shoutcast_station.get_path()
                stations.append(station)
            #end for
        #end if

        if (not stations):
            self.__current_folder.message = "station list not available"
            logging.error("SHOUTcast station listing download failed\n%s",
                          logging.stacktrace())

        stations.sort()
        return stations
Beispiel #28
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
Beispiel #29
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
Beispiel #30
0
    def __parse_group(self, parent_path, node_nr, node):
    
        f = File(self)
        try:
            f.name = node.get_attr("title")
        except:
            return None
        f.path = File.pack_path(parent_path, `node_nr`, f.name, "")
        f.mimetype = f.DIRECTORY

        if (f.name in _BLACKLISTED):
            return None

        return f