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 9 -class Shoutable(object):
10 - def init(self, api):
11 self._api = api
12 13 @LastfmBase.cached_property
14 - def shouts(self):
15 """shouts for this ssubject""" 16 from lastfm.shout import Shout 17 from lastfm.user import User 18 params = self._default_params({'method': '%s.getShouts' % self.__class__.__name__.lower()}) 19 data = self._api._fetch_data(params).find('shouts') 20 return [ 21 Shout( 22 body = s.findtext('body'), 23 author = User(self._api, name = s.findtext('author')), 24 date = s.findtext('date') and s.findtext('date').strip() and \ 25 datetime(*(time.strptime(s.findtext('date').strip(), '%a, %d %b %Y %H:%M:%S')[0:6])) 26 ) 27 for s in data.findall('shout') 28 ]
29 30 @LastfmBase.top_property("shouts")
31 - def recent_shout(self):
32 """recent shout for this subject""" 33 pass
34
35 - def _default_params(self, extra_params = {}):
36 return extra_params
37 38 from datetime import datetime 39 import time 40