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
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
def __ls_search(self, path, cb, *args): prefix, name, category, query, idx = File.unpack_path(path) #print path #print prefix, name, category, query, idx if (category == "video"): self.__video_search(cb, args, query, idx) else: self.__category_search(category, cb, args, idx)
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
def get_contents(self, folder, begin_at, end_at, cb, *args): if (not self.__tv_dom): folder.message = "Please install WorldTV" cb(None, *args) return else: folder.message = "" parts = [ p for p in folder.path.split("/") if p ] node = self.__tv_dom for p in parts: if (not p): continue prefix, node_nr, name, url = File.unpack_path(p) node = node.get_children()[int(node_nr)] #end for cnt = 0 items = [] parent_path = folder.path for c in node.get_children(): if (c.get_name() == "group"): f = self.__parse_group(parent_path, cnt, c) elif (c.get_name() == "item"): f = self.__parse_item(parent_path, cnt, c) elif (c.get_name() == "link"): f = self.__parse_link(parent_path, cnt, c) else: f = None if (f): items.append(f) cnt += 1 #end for items.sort() cnt = -1 for item in items: cnt += 1 if (cnt < begin_at): continue if (end_at and cnt > end_at): break cb(item, *args) #end for cb(None, *args)
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
def get_contents(self, folder, begin_at, end_at, cb, *args): parts = File.unpack_path(folder.path) prefix = parts[0] items = [] if (prefix == "/"): # list months query = "Image.Month, Image.Year of and " \ "File.Folder='DCIM' " \ "File.Type='image'" res = self.call_service(msgs.FILEINDEX_SVC_QUERY, query) for month, year in res: f = self.__make_folder(month, year) if (f): items.append(f) #end for elif (prefix == "/months"): month, year = parts[1:] month = int(month) year = int(year) query = "File.Path of and and " \ "File.Folder='DCIM' " \ "File.Type='image' " \ "and Image.Month=%d Image.Year=%d" \ % (month, year) res = self.call_service(msgs.FILEINDEX_SVC_QUERY, query) for path, in res: f = self.call_service(msgs.CORE_SVC_GET_FILE, path) if (f): items.append(f) #end if items.sort() cnt = -1 for item in items: cnt += 1 if (cnt < begin_at): continue if (end_at and cnt > end_at): break cb(item, *args) #end for cb(None, *args)
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
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
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
def get_contents(self, folder, begin_at, end_at, cb, *args): path = folder.path parts = File.unpack_path(path) prefix = parts[0] items = [] if (prefix == "/"): # list genres res = self.call_service(msgs.FILEINDEX_SVC_QUERY, "Audio.Genre of File.Type='audio'") for genre, in res: f = self.__make_genre(genre) if (f): items.append(f) #end for elif (prefix == "/genres"): # list albums genre = parts[1] res = self.call_service(msgs.FILEINDEX_SVC_QUERY, "File.Folder, Audio.Album of and File.Type='audio'" \ "Audio.Genre='%s'", genre) for ffolder, album in res: f = self.__make_album(ffolder, album) if (f): items.append(f) #end for #end if items.sort() cnt = -1 for item in items: cnt += 1 if (cnt < begin_at): continue if (end_at and cnt > end_at): break cb(item, *args) #end for cb(None, *args)
def get_contents(self, folder, begin_at, end_at, cb, *args): path = folder.path parts = File.unpack_path(path) prefix = parts[0] items = [] if (prefix == "/"): # list artists res = self.call_service(msgs.FILEINDEX_SVC_QUERY, "Audio.Artist of File.Type='audio'") for artist, in res: f = self.__make_artist(artist) if (f): items.append(f) #end for elif (prefix == "/artists"): # list albums artist = parts[1] res = self.call_service(msgs.FILEINDEX_SVC_QUERY, "File.Folder, Audio.Album " \ "of and File.Type='audio' Audio.Artist='%s'", artist) #res.add(("All Tracks",)) for ffolder, album in res: f = self.__make_album(ffolder, album) if (f): items.append(f) #end for items.sort() cnt = -1 for item in items: cnt += 1 if (cnt < begin_at): continue if (end_at and cnt > end_at): break cb(item, *args) #end for cb(None, *args)
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
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
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
def get_contents(self, folder, begin_at, end_at, cb, *args): def file_cmp(a, b): if (a.name == "All Tracks"): return -1 if (b.name == "All Tracks"): return 1 else: return cmp(a.comparable, b.comparable) path = folder.path parts = File.unpack_path(path) prefix = parts[0] items = [] if (prefix == "/"): if (self.__cache): items += self.__cache else: # list albums res = self.call_service( msgs.FILEINDEX_SVC_QUERY, "File.Folder, Audio.Album of File.Type='audio'") res.add(("All Tracks", "All Tracks")) for ffolder, album in res: if (not album): continue f = self.__make_album(ffolder, album) if (f): items.append(f) #end for self.__cache = items[:] #end if elif (prefix == "/albums"): # list tracks ffolder, album = parts[1:] if (album == "All Tracks"): query = "File.Path, File.Format, " \ "Audio.Title, Audio.Artist, Audio.Tracknumber " \ "of File.Type='audio'" query_args = () else: query = "File.Path, File.Format, " \ "Audio.Title, Audio.Artist, Audio.Tracknumber " \ "of and and File.Type='audio' " \ "File.Folder='%s' Audio.Album='%s'" query_args = (ffolder, album) res = self.call_service(msgs.FILEINDEX_SVC_QUERY, query, *query_args) for filepath, mimetype, title, artist, trackno in res: f = self.__make_track(artist, album, title, trackno, filepath, mimetype) if (f): items.append(f) #end for #end if items.sort(file_cmp) cnt = -1 for item in items: cnt += 1 if (cnt < begin_at): continue if (end_at and cnt > end_at): break cb(item, *args) #end for cb(None, *args)