| 280 | | if menuw: |
| 281 | | AlertBox(text=_('Cannot get XSFP')).show() |
| 282 | | traceback.print_stack() |
| 283 | | rc.post_event(STOP) |
| 284 | | return |
| 285 | | except LastFMError, why: |
| 286 | | _debug_(why, DWARNING) |
| 287 | | if menuw: |
| 288 | | AlertBox(text=str(why)).show() |
| 289 | | rc.post_event(STOP) |
| 290 | | return |
| 291 | | |
| 292 | | entry = self.feed.entries[0] |
| 293 | | _debug_('entry "%s / %s / %s" of %s' % (entry.artist, entry.album, entry.title, len(self.feed.entries))) |
| 294 | | self.stream_name = urllib.unquote_plus(self.feed.title) |
| 295 | | self.album = entry.album |
| 296 | | self.artist = entry.artist |
| 297 | | self.title = entry.title |
| 298 | | self.location_url = entry.location_url |
| 299 | | self.length = entry.duration |
| 300 | | basename = os.path.join(config.LASTFM_DIR, self.stream_name, entry.artist, entry.album, entry.title) |
| 301 | | self.basename = basename.lower().replace(' ', '_').\ |
| 302 | | replace('.', '').replace('\'', '').replace(':', '').replace(',', '') |
| 303 | | if not os.path.exists(os.path.dirname(self.basename)): |
| 304 | | _debug_('make directory %r' % (os.path.dirname(self.basename),), DINFO) |
| 305 | | os.makedirs(os.path.dirname(self.basename), 0777) |
| 306 | | # url is changed, to include file:// |
| 307 | | self.url = os.path.join(self.basename + os.path.splitext(entry.location_url)[1]) |
| 308 | | self.trackpath = os.path.join(self.basename + os.path.splitext(entry.location_url)[1]) |
| 309 | | self.track_downloader = self.webservices.download(self.location_url, self.trackpath) |
| 310 | | if entry.image_url: |
| 311 | | self.image = os.path.join(self.basename + os.path.splitext(entry.image_url)[1]) |
| 312 | | self.image_downloader = self.webservices.download(entry.image_url, self.image) |
| 313 | | # Wait three seconds for the image to be downloaded |
| 314 | | for i in range(30): |
| 315 | | if not self.image_downloader.isrunning(): |
| 316 | | break |
| | 281 | raise LastFMError('Cannot get XSFP') |
| | 282 | |
| | 283 | entry = self.feed.entries[0] |
| | 284 | _debug_('entry "%s / %s / %s" of %s' % (entry.artist, entry.album, entry.title, len(self.feed.entries))) |
| | 285 | self.stream_name = urllib.unquote_plus(self.feed.title) |
| | 286 | self.album = entry.album |
| | 287 | self.artist = entry.artist |
| | 288 | self.title = entry.title |
| | 289 | self.location_url = entry.location_url |
| | 290 | self.length = entry.duration |
| | 291 | basename = os.path.join(config.LASTFM_DIR, self.stream_name, entry.artist, entry.album, entry.title) |
| | 292 | self.basename = basename.lower().replace(' ', '_').\ |
| | 293 | replace('.', '').replace('\'', '').replace(':', '').replace(',', '') |
| | 294 | if not os.path.exists(os.path.dirname(self.basename)): |
| | 295 | _debug_('make directory %r' % (os.path.dirname(self.basename),), DINFO) |
| | 296 | os.makedirs(os.path.dirname(self.basename), 0777) |
| | 297 | # url is changed, to include file:// |
| | 298 | self.url = os.path.join(self.basename + os.path.splitext(entry.location_url)[1]) |
| | 299 | self.trackpath = os.path.join(self.basename + os.path.splitext(entry.location_url)[1]) |
| | 300 | if entry.image_url: |
| | 301 | self.image = os.path.join(self.basename + os.path.splitext(entry.image_url)[1]) |
| | 302 | self.image_downloader = self.webservices.download(entry.image_url, self.image) |
| | 303 | # Wait three seconds for the image to be downloaded |
| | 304 | for i in range(30): |
| | 305 | if not self.image_downloader.isrunning(): |
| | 306 | break |
| | 307 | time.sleep(0.1) |
| | 308 | else: |
| | 309 | self.image = None |
| | 310 | self.track_downloader = self.webservices.download(self.location_url, self.trackpath, self) |
| | 311 | # Wait for a bit of the file to be downloaded |
| | 312 | while self.track_downloader.filesize() < 1024 * 20: |
| | 313 | if not self.track_downloader.isrunning(): |
| | 314 | raise LastFMError('Failed to download track', entry.location_url) |
| 318 | | else: |
| 319 | | self.image = None |
| 320 | | #self.is_playlist = True |
| 321 | | # Wait for a bit of the file to be downloaded |
| 322 | | while self.track_downloader.filesize() < 1024 * 20: |
| 323 | | if not self.track_downloader.isrunning(): |
| 324 | | traceback.print_stack() |
| 325 | | rc.post_event(STOP) |
| 326 | | return |
| 327 | | time.sleep(0.1) |
| 328 | | self.player = PlayerGUI(self, menuw) |
| 329 | | error = self.player.play() |
| 330 | | if error: |
| 331 | | _debug_('player play error=%r' % (error,), DWARNING) |
| 332 | | if menuw: |
| 333 | | AlertBox(text=error).show() |
| 334 | | traceback.print_stack() |
| 335 | | rc.post_event(STOP) |
| 336 | | finally: |
| 337 | | if pop is not None: |
| 338 | | pop.destroy() |
| | 316 | self.player = PlayerGUI(self, menuw) |
| | 317 | error = self.player.play() |
| | 318 | if error: |
| | 319 | raise LastFMError('Play error=%r' % (error,)) |
| | 320 | finally: |
| | 321 | if pop is not None: |
| | 322 | pop.destroy() |
| | 323 | except LastFMError, why: |
| | 324 | _debug_('player play error=%r' % (error,), DWARNING) |
| | 325 | if menuw: |
| | 326 | AlertBox(text=str(why)).show() |
| | 327 | rc.post_event(STOP) |
| | 328 | return |