Package lastfm :: Package mixins :: Module shoutable
[hide private]
[frames] | no frames]

Source Code for Module lastfm.mixins.shoutable

 1  #!/usr/bin/env python 
 2   
 3  __author__ = "Abhinav Sarkar <abhinav@abhinavsarkar.net>" 
 4  __version__ = "0.2" 
 5  __license__ = "GNU Lesser General Public License" 
 6   
 7  from lastfm.base import LastfmBase 
 8  from lastfm.decorators import cached_property, top_property 
9 10 -class Shoutable(object):
11 - def init(self, api):
12 self._api = api
13 14 @cached_property
15 - def shouts(self):
16 """shouts for this ssubject""" 17 from lastfm.shout import Shout 18 from lastfm.user import User 19 params = self._default_params({'method': '%s.getShouts' % self.__class__.__name__.lower()}) 20 data = self._api._fetch_data(params).find('shouts') 21 return [ 22 Shout( 23 body = s.findtext('body'), 24 author = User(self._api, name = s.findtext('author')), 25 date = s.findtext('date') and s.findtext('date').strip() and \ 26 datetime(*(time.strptime(s.findtext('date').strip(), '%a, %d %b %Y %H:%M:%S')[0:6])) 27 ) 28 for s in data.findall('shout') 29 ]
30 31 @top_property("shouts")
32 - def recent_shout(self):
33 """recent shout for this subject""" 34 pass
35
36 - def _default_params(self, extra_params = {}):
37 return extra_params
38 39 from datetime import datetime 40 import time 41