LastfmArchive.sync

You're seeing just the function sync, go back to LastfmArchive module for more information.

Specs

sync() :: :ok | {:error, :file.posix()}

Sync scrobbles of a default user specified in configuration.

Example

  LastfmArchive.sync

The default user is specified in configuration, for example user_a in config/config.exs:

  config :lastfm_archive,
    user: "user_a",
    ... # other archiving options

See sync/2 for further details and archiving options.

Link to this function

sync(user, options \\ [])

View Source

Specs

sync(binary(), keyword()) :: :ok | {:error, :file.posix()}

Sync scrobbles for a Lastfm user.

Example

  LastfmArchive.sync("a_lastfm_user")

The first sync downloads all daily scrobbles in 200-track (gzip compressed) chunks that are written into a local file archive. Subsequent syncs extract further scrobbles starting from the date of latest downloaded scrobbles.

The data is currently in raw Lastfm recenttracks JSON format, chunked into 200-track (max) gzip compressed pages and stored within directories corresponding to the days when tracks were scrobbled.

Options:

  • :interval - default 1000(ms), the duration between successive Lastfm API requests. This provides a control for request rate. The default interval ensures a safe rate that is within Lastfm's term of service: no more than 5 requests per second

  • :overwrite - default false (not available currently), if sets to true the system will (re)fetch and overwrite any previously downloaded data. Use this option to refresh the file archive. Otherwise (false), the system will not be making calls to Lastfm to check and re-fetch data if existing data chunks / pages are found. This speeds up archive updating

  • :per_page - default 200, number of scrobbles per page in archive. The default is the max number of tracks per request permissible by Lastfm

  • :data_dir - default lastfm_data. The file archive is created within a main data directory, e.g. ./lastfm_data/a_lastfm_user/.

These options can be configured in config/config.exs:

  config :lastfm_archive,
    ...
    data_dir: "./lastfm_data/"