Home | Trees | Indices | Help |
---|
|
1 # -*- coding: utf-8 -*- 2 # Elisa - Home multimedia server 3 # Copyright (C) 2006-2008 Fluendo Embedded S.L. (www.fluendo.com). 4 # All rights reserved. 5 # 6 # This file is available under one of two license agreements. 7 # 8 # This file is licensed under the GPL version 3. 9 # See "LICENSE.GPL" in the root of this distribution including a special 10 # exception to use Elisa with Fluendo's plugins. 11 # 12 # The GPL part of Elisa is also available under a commercial licensing 13 # agreement from Fluendo. 14 # See "LICENSE.Elisa" in the root directory of this distribution package 15 # for details on that license. 16 17 """ 18 This media provider provides access to the rss://-scheme and reads the 19 enclosures, if there are some or the describtion for images. 20 21 To use it follow these steps: 22 Get to your favorite podcast-website. copy the link of the rss, and paste it 23 into the locations of the audio activity for audio-data, in the video activity 24 for videos or in the image activity for images. Now remove the 'http' and 25 replace it with rss: 26 http://www.rocketboom.com/vlog/quicktime_daily_enclosures.xml 27 = rss://www.rocketboom.com/vlog/quicktime_daily_enclosures.xml 28 29 30 This URI is now accessible in your audio (or video) menu inside browse by 31 folder. 32 33 Enjoy it! 34 35 36 Troubleshooting: 37 You get no Children, but it is not loading anymore? 38 1. Are you sure that you entered in the right activity? Podcasts are 39 NOT shown in video activity and the other way round. 40 2. Are you sure, that the requested data is in there? To check this for 41 videos/audios do this: 42 Be sure that the rss you are using really has the enclosure tag. For this, 43 you can just download the file and read it with your favorite editor. 44 Look for the word 'enclosure'. If you don't find any, your blog does not 45 support it and we can't read it. 46 If you have problem with images, do this: 47 You can just take a look with Firefox (> 2.0) at the file. If there are 48 images appearing, this plugin should also be able to find them. 49 50 If you are sure, that it should work, but it doesn't: feel free to file a ticket 51 on the elisa trac. Don't forget to paste your link there and also, how you did 52 the troubleshooting! 53 """ 54 55 56 __maintainer__ = 'Benjamin Kampmann <benjamin@fluendo.com>' 57 58 from elisa.base_components.media_provider import MediaProvider 59 from elisa.core.media_uri import MediaUri, quote, unquote 60 from elisa.core.media_file import MediaFile 61 62 from elisa.extern.coherence.et import parse_xml 63 64 import urllib2, re 6567 """ 68 This reads the enclosures for an rss-scheme... 69 """ 70 71 reg_img_src = re.compile("<img.src=\"(.*?)\"") 72 77 80 84165 166 167 if __name__ == "__main__": 168 169 m = PodcatcherMedia() 170 uri = MediaUri('rss://www.brennpunkt-ostkreuz.de/rssfeed/Brennpunktgeschichten.rss') 171 list = [] 172 178 179 a = m.get_direct_children(uri, list) 180 a.addCallback(printer) 181 182 try: 183 from twisted.internet import glib2reactor 184 glib2reactor.install() 185 except AssertionError: 186 # already installed... 187 pass 188 189 from twisted.internet import reactor 190 191 reactor.run() 19286 media_type = {} 87 if self._blocking_is_directory(uri): 88 media_type = {'file_type': 'directory', 'mime_type': ''} 89 else: 90 media_type = self._children.get(uri, None) 91 return media_type9294 return uri.host != 'CHILD'9597 has_children = False 98 if self._blocking_is_directory(uri): 99 ## we need a kind of a MAYBE-Opertor. We don't know, if there 100 ## are this children, before accessing... 101 has_children = True 102 return has_children103 107109 if self._blocking_is_directory(uri) and not uri in self._cached: 110 real_http = "http%s" % str(uri)[3:] 111 self.debug("Real URI is %s" % real_http) 112 113 data = self._get_url_data(real_http) 114 115 parsed = parse_xml(data) 116 117 for entry in parsed.findall('channel/item'): 118 title = entry.find('title').text.lstrip() 119 desc = entry.find('description') 120 enclos = entry.find('enclosure') 121 122 if enclos != None: 123 url = enclos.attrib['url'] 124 length = enclos.attrib['length'] 125 type = enclos.attrib['type'] 126 media = None 127 if 'audio' in type: 128 media = 'audio' 129 elif 'video' in type: 130 media = 'video' 131 ### Is this also existing for images? 132 if url and media: 133 uri = MediaUri('rss://CHILD/%s' % quote(url)) 134 uri.label = title 135 content = {'file_type' : media, 136 'mime_type' : type, 137 'default_image' : None, 138 'length' : length} 139 self._children[uri] = content 140 children.append( (uri, content) ) 141 elif desc != None: 142 # No real enclosures found. So let's search in the desc. 143 # currently only supported for images! 144 145 # The data should be quoted HTML. 146 data = unquote(desc.text) 147 data = data.replace("'","'") 148 search = self.reg_img_src.search(data) 149 if search != None: 150 for entry in search.groups(): 151 content = {'file_type' : 'image', 152 'media_type': '', 153 'default_image' : MediaUri(entry) } 154 155 uri = MediaUri('rss://CHILD/%s' % quote(entry)) 156 uri.label = title 157 self._children[uri] = content 158 children.append( (uri, content) ) 159 160 161 return children162
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0beta1 on Wed Jan 16 19:10:41 2008 | http://epydoc.sourceforge.net |