~ubuntu-branches/ubuntu/saucy/radiotray/saucy

« back to all changes in this revision

Viewing changes to src/RamPlaylistDecoder.py

  • Committer: Package Import Robot
  • Author(s): Elías Alejandro Año Mendoza
  • Date: 2011-12-28 17:06:38 UTC
  • mfrom: (6.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20111228170638-cym2rxl7boqq8dxr
Tags: 0.7.1-1
* New upstream release
* debian/copyright
  + Added new copyright owners

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
##########################################################################
20
20
import urllib2
21
21
from lib.common import USER_AGENT
 
22
import logging
22
23
 
23
24
class RamPlaylistDecoder:
24
25
 
25
26
    def __init__(self):
26
 
        print "RAM playlist decoder"
 
27
        self.log = logging.getLogger('radiotray')
 
28
        self.log.debug('RAM playlist decoder')
27
29
 
28
30
    def isStreamValid(self, contentType, firstBytes):
29
31
 
30
32
        if('audio/x-pn-realaudio' in contentType or 'audio/vnd.rn-realaudio' in contentType):
31
 
            print 'Stream is readable by RAM Playlist Decoder'
 
33
            self.log.info('Stream is readable by RAM Playlist Decoder')
32
34
            return True
33
35
        else:
34
36
            return False
36
38
 
37
39
 
38
40
    def extractPlaylist(self,  url):
39
 
        print "Downloading playlist..."
 
41
        self.log.info('Downloading playlist...')
40
42
 
41
43
        req = urllib2.Request(url)
42
44
        req.add_header('User-Agent', USER_AGENT)
44
46
        str = f.read()
45
47
        f.close()
46
48
 
47
 
        print "Playlist downloaded"
48
 
        print "Decoding playlist..."
 
49
        self.log.info('Playlist downloaded')
 
50
        self.log.info('Decoding playlist...')
49
51
 
50
52
        lines = str.splitlines()
51
53
        playlist = []