Re-add get_weekly_album_charts(), get_weekly_artist_charts() and get_weekly_charts() helper functions

This commit is contained in:
hugovk 2014-03-07 20:22:14 +02:00
parent 4c4e3bfbba
commit c3d99385ff
2 changed files with 30 additions and 6 deletions

View file

@ -1368,14 +1368,38 @@ class _BaseObject(object):
return seq return seq
def get_weekly_charts(self, chart_kind, from_date=None, to_date=None): def get_weekly_album_charts(self, from_date=None, to_date=None):
"""
Returns the weekly album charts for the week starting from the
from_date value to the to_date value.
Only for Group or User.
"""
return self.get_weekly_charts("album", from_date, to_date)
def get_weekly_artist_charts(self, from_date=None, to_date=None):
"""
Returns the weekly artist charts for the week starting from the
from_date value to the to_date value.
Only for Group, Tag or User.
"""
return self.get_weekly_charts("artist", from_date, to_date)
def get_weekly_track_charts(self, from_date=None, to_date=None):
""" """
Returns the weekly track charts for the week starting from the Returns the weekly track charts for the week starting from the
from_date value to the to_date value. from_date value to the to_date value.
chart_kind should be one of "album", "track" Only for Group or User.
"""
return self.get_weekly_charts("track", from_date, to_date)
def get_weekly_charts(self, chart_kind, from_date=None, to_date=None):
"""
Returns the weekly charts for the week starting from the
from_date value to the to_date value.
chart_kind should be one of "album", "artist" or "track"
""" """
method = ".getWeekly" + chart_kind.title() + "Chart" method = ".getWeekly" + chart_kind.title() + "Chart"
chart_type = eval(chart_kind.title()) chart_type = eval(chart_kind.title()) # string to type
params = self._get_params() params = self._get_params()
if from_date and to_date: if from_date and to_date:

View file

@ -1179,10 +1179,10 @@ class TestPyLast(unittest.TestCase):
(from_date, to_date) = date (from_date, to_date) = date
# Act # Act
artist_chart = thing.get_weekly_charts("artist", from_date, to_date) artist_chart = thing.get_weekly_artist_charts(from_date, to_date)
if type(thing) is not pylast.Tag: if type(thing) is not pylast.Tag:
album_chart = thing.get_weekly_charts("album", from_date, to_date) album_chart = thing.get_weekly_album_charts(from_date, to_date)
track_chart = thing.get_weekly_charts("track", from_date, to_date) track_chart = thing.get_weekly_track_charts(from_date, to_date)
# Assert # Assert
self.helper_assert_chart(artist_chart, pylast.Artist) self.helper_assert_chart(artist_chart, pylast.Artist)