Esempio n. 1
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
Esempio n. 2
0
 def __parse_item(self, path, node):
 
     try:
         name = node.get_attr("title")
         url = node.get_attr("url")
     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 = path
     f.mimetype = "video/x-unknown"
     f.thumbnail = theme.worldtv_device.get_path()
     
     return f
Esempio n. 3
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