Пример #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
Пример #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
Пример #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)
Пример #4
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
Пример #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
Пример #6
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
Пример #7
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")
Пример #8
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")
Пример #9
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
Пример #10
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
Пример #11
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
Пример #12
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
Пример #13
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
Пример #14
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
Пример #15
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
Пример #16
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
Пример #17
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
Пример #18
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
Пример #19
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
Пример #20
0
 def __make_station(self, name, url):
 
     f = File(self)
     f.name = name
     f.info = url
     f.path = File.pack_path("/", name, url)
     f.resource = url
     if (url.endswith(".ram") or url.endswith(".rm")):
         f.mimetype = "application/vnd.rn-realmedia"
     else:
         f.mimetype = "audio/x-unknown"
     f.thumbnailer = "iradio.IRadioThumbnailer"
     f.thumbnailer_param = url
     
     return f
Пример #21
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
Пример #22
0
    def __parse_stations(self, data, genre):
        """
        Parses the XML list of stations.
        """

        stations = []
        try:
            dtree = ElementTree.parse(StringIO(data))
            for i in dtree.getiterator():
                if i.tag == "station":
                    # build station object
                    station = File(self)
                    bitrate = "-"
                    now_playing = "-"
                    
                    for j,n in i.items():
                        if j == "name":
                            station.name = n
                        elif j == "ct":
                            now_playing = n
                        elif j == "id":
                            station.resource = _SHOUTCAST_BASE + "/sbin/shoutcast-playlist.pls?rn=%s&file=filename.pls" % n
                        elif j == "br":
                            bitrate = n
                        elif j == "mt":
                            station.mimetype = n

                    station.path = "/" + genre + "/" + \
                                   self.__encode_station(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
                    stations.append(station)

        except:
            self.call_service(msgs.UI_ACT_SHOW_INFO,
                              "An error occured while loading the list of stations.\n" \
                              "Check your internet connection and try again.")
            logging.error("SHOUTcast station listing download failed\n%s",
                          logging.stacktrace())

        stations.sort()
        return stations
Пример #23
0
 def __make_station(self, s):
 
     try:
         name, bitrate, mimetype, location, genre = self.__decode_station(s)
     except:
         logging.error("error decoding iradio path: %s\n%s",
                         path, logging.stacktrace())
         return None
     
     f = File(self)
     f.name = name
     f.info = "Bitrate: %s kb" % bitrate
     f.resource = location
     f.path = "/" + urlquote.quote(genre, "") + "/" + s
     f.mimetype = mimetype
     f.icon = theme.shoutcast_station.get_path()
     
     return f       
Пример #24
0
    def __make_station(self, s):

        try:
            prefix, name, bitrate, mimetype, location, genre = File.unpack_path(
                s)
        except:
            logging.error("error decoding iradio path: %s\n%s", path,
                          logging.stacktrace())
            return None

        f = File(self)
        f.name = name
        f.info = "Bitrate: %s kb" % bitrate
        f.resource = location
        f.path = s
        f.mimetype = mimetype
        f.icon = theme.shoutcast_station.get_path()

        return f
Пример #25
0
    def get_file(self, path):

        try:
            name, location = self.__decode_path(path)
        except:
            logging.error("error decoding iradio path: %s\n%s", path,
                          logging.stacktrace())
            return None

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

        return f
Пример #26
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
Пример #27
0
    def __make_video(self, path):
        """
        Creates a video file object from the given path.
        """

        prefix, title, info, video_id, thumbnail_url = File.unpack_path(path)

        f = File(self)
        f.name = title
        f.resource = video_id
        f.path = path
        f.mimetype = "video/x-flash-video"

        if (video_id == _REGION_BLOCKED):
            f.info = "This video cannot be viewed in your country."
            f.icon = theme.youtube_restricted.get_path()
        else:
            f.info = info
            f.thumbnailer = "youtube.YouTubeThumbnailer"
            f.thumbnailer_param = thumbnail_url

        return f
Пример #28
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.DEVICE_ROOT
            f.resource = ""
            f.name = self.get_name()
            f.icon = self.get_icon().get_path()
            f.info = "Browse your music library by genre"

        elif (prefix == "/genres"):
            # genre
            genre = parts[1]
            f = self.__make_genre(genre)

        return f
Пример #29
0
    def __make_track(self, artist, album, title, trackno, resource, mimetype):

        #f = self.call_service(msgs.CORE_SVC_GET_FILE, resource)
        #if (not f): return None

        path = File.pack_path("/tracks", artist, album, title, trackno,
                              resource, mimetype)

        f = File(self)
        f.path = path
        f.is_local = True
        f.resource = resource
        f.name = title
        f.info = artist or "unknown"
        f.mimetype = mimetype
        f.acoustic_name = f.name + ", by " + f.info

        if (album == "All Tracks"):
            f.comparable = f.name.upper()
        else:
            f.comparable = trackno

        return f
Пример #30
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.DEVICE_ROOT
            f.resource = ""
            f.name = self.get_name()
            f.icon = self.get_icon().get_path()
            f.info = "Browse your music library by artist"
            #f.folder_flags = f.ITEMS_COMPACT
            
        elif (prefix == "/artists"):
            # artist
            artist = parts[1]
            f = self.__make_artist(artist)
    
        return f