#######
Last.fm
#######
You can fetch all your Scrobbles (listens) from one or more `Last.fm
{{ row.year }}: {{ row.count }}
{% endfor %} Both the ``year`` and ``count`` in each row are integers. To restrict totals to a single ``Account`` (assuming ``account`` is an ``Account`` object): .. code-block:: django {% annual_scrobble_counts account=account as counts %} Day Scrobbles ============= Get a QuerySet of all Scrobbles from a particular day for one or all ``Account`` s, earliest first. In these examples, ``today`` can be either a ``datetime.datetime`` or a ``datetime.date``. .. code-block:: django {% load ditto_lastfm %} {% day_scrobbles date=today as scrobbles %} {% for scrobble in scrobbles %}{{ scrobble.artist.name }} - {{ scrobble.track.name }} ({{ scrobble.post_time }})
{% endfor %} To restrict scrobbles to a single ``Account`` (assuming ``account`` is an ``Account`` object): .. code-block:: django {% day_scrobbles date=today account=account as scrobbles %} Recent Scrobbles ================ Get a QuerySet of the most recent Scrobbles, by one or all ``Account`` s. The default quantity returned is 10. .. code-block:: django {% load ditto_lastfm %} {% recent_scrobbles as scrobbles %} {# Then loop as in previous example. #} To restrict scrobbles to a single ``Account`` (assuming ``account`` is an ``Account`` object), and increase the quantity returned to 30: .. code-block:: django {% recent_scrobbles account=account limit=30 as scrobbles %} Top Tracks ========== Get a QuerySet of the most-scrobbled ``Track`` s with the most-scrobbled first. Can be restricted to: a single ``Account``; a single day, week, month or year; tracks by a single ``Artist``. By default 10 tracks are returned. .. code-block:: django {% load ditto_lastfm %} {% top_tracks as tracks %} {% for track in tracks %}{{ forloop.counter }}. {{ track.artist.name }} - {{ track.name }}: {{ track.scrobble_count }}
{% endfor %} Examples of fetching for a single day, month or year, assuming ``my_date`` is either a ``datetime.datetime`` or a ``datetime.date``: .. code-block:: django {% top_tracks date=my_date period='day' as tracks %} {% top_tracks date=my_date period='week' as tracks %} {% top_tracks date=my_date period='month' as tracks %} {% top_tracks date=my_date period='year' as tracks %} For month and year, the calendar month/year around the date is used. e.g. if the supplied date was ``2016-03-24`` then ``period='month'`` would produce a chart for March 2016, and ``period='year'`` would produce a chart for all of 2016. For week, it uses the Django setting ``FIRST_DAY_OF_WEEK``, default being ``0`` (Sunday). Example of only fetching tracks by a single artist, assuming ``artist`` is an ``Artist`` object: .. code-block:: django {% top_tracks artist=artist as tracks %} Example of only fetching tracks scrobbled by a single ``Account``: .. code-block:: django {% top_tracks account=account as tracks %} Example of fetching only 5 tracks by a single ``Artist``, scrobbled by a single ``Account``, during a single month: .. code-block:: django {% top_tracks artist=artist account=account date=my_date period='month' limit=5 as tracks %} Arguments can be in any order. Top Albums ========== Get a QuerySet of the most-scrobbled ``Album`` s with the most-scrobbled first. This works in exactly the same way as the ``top_tracks`` template tag, above, with identical arguments. e.g.: .. code-block:: django {% load ditto_lastfm %} {% top_albums artist=artist account=account date=my_date period='month' limit=5 as albums %} {% for album in albums %}{{ forloop.counter }}. {{ album.artist.name }} - {{ album.name }}: {{ album.scrobble_count }}
{% endfor %} Top Artists =========== Get a QuerySet of the most-scrobbled ``Artist`` s with the most-scrobbled first. This works in a similar way to the ``top_tracks`` and ``top_albums`` template tags, above. The only difference is that results cannot be filtered by ``artist``. e.g.: .. code-block:: django {% load ditto_lastfm %} {% top_artists account=account date=my_date period='month' limit=5 as artists %} {% for artist in artists %}{{ forloop.counter }}. {{ artist.name }}: {{ album.scrobble_count }}
{% endfor %} .. _lastfm-management-commands: ******************* Management commands ******************* There is only one Last.fm management command. Fetch Scrobbles =============== Fetches Scrobbles for one or all Accounts. To fetch ALL Scrobbles for all Accounts (this could take a long time): .. code-block:: shell $ ./manage.py fetch_lastfm_scrobbles --days=all To fetch Scrobbles for all Accounts from the past 3 days: .. code-block:: shell $ ./manage.py fetch_lastfm_scrobbles --days=3 Both options can be restricted to only fetch for a single Account by adding the Last.fm username. e.g.: .. code-block:: shell $ ./manage.py fetch_lastfm_scrobbles --account=gyford --days=3 It's safe to re-fetch the same data. Duplicates will only occur if an Artist/Track/Album's URL slug has changed. A change of case won't cause duplicates, but anything more will. Subsequent fetches will update any other changed data, such as altered Artist names, new or different MBIDs, etc.