Documentation
¶
Overview ¶
Package to parse and write .scrobbler.log files as written by Rockbox.
The parser supports reading version 1.1 and 1.0 of the scrobbler log file format. The latter is only supported if encoded in UTF-8.
When written it always writes version 1.1 of the scrobbler log file format, which includes the MusicBrainz recording ID as the last field of each row.
See - https://www.rockbox.org/wiki/LastFMLog - https://git.rockbox.org/cgit/rockbox.git/tree/apps/plugins/lastfm_scrobbler.c - https://web.archive.org/web/20110110053056/http://www.audioscrobbler.net/wiki/Portable_Player_Logging
Index ¶
- type Rating
- type Record
- type ScrobblerLog
- func (l *ScrobblerLog) Append(data io.Writer, records []Record) (lastTimestamp time.Time, err error)
- func (l *ScrobblerLog) Parse(data io.Reader, ignoreSkipped bool) error
- func (l *ScrobblerLog) ParseIter(data io.Reader, ignoreSkipped bool) iter.Seq2[Record, error]
- func (l *ScrobblerLog) ReadHeader(reader io.Reader) error
- func (l *ScrobblerLog) WriteHeader(writer io.Writer) error
- type TZInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Record ¶
type Record struct {
ArtistName string
AlbumName string
TrackName string
TrackNumber int
Duration time.Duration
Rating Rating
Timestamp time.Time
MusicBrainzRecordingID mbtypes.MBID
}
A single entry of a track in the scrobbler log file.
type ScrobblerLog ¶
type ScrobblerLog struct {
TZ TZInfo
Client string
Records []Record
// Timezone to be used for timestamps in the log file,
// if TZ is set to [TimezoneUnknown].
FallbackTimezone *time.Location
}
Represents a scrobbler log file.
func (*ScrobblerLog) Append ¶
func (l *ScrobblerLog) Append(data io.Writer, records []Record) (lastTimestamp time.Time, err error)
Append writes the given records to the writer.
The writer should be for an existing scrobbler log file or ScrobblerLog.WriteHeader should be called before this function. Returns the last timestamp of the records written.
func (*ScrobblerLog) Parse ¶
func (l *ScrobblerLog) Parse(data io.Reader, ignoreSkipped bool) error
Parses a scrobbler log file from the given reader.
The reader must provide a valid scrobbler log file with a valid header. This function implicitly calls ScrobblerLog.ReadHeader.
func (*ScrobblerLog) ParseIter ¶ added in v0.6.0
Parses a scrobbler log file from the given reader and returns an iterator over all records.
The reader must provide a valid scrobbler log file with a valid header. This function implicitly calls ScrobblerLog.ReadHeader.
func (*ScrobblerLog) ReadHeader ¶
func (l *ScrobblerLog) ReadHeader(reader io.Reader) error
Parses just the header of a scrobbler log file from the given reader.
This function sets [ScrobblerLog.TZ] and [ScrobblerLog.Client].
func (*ScrobblerLog) WriteHeader ¶
func (l *ScrobblerLog) WriteHeader(writer io.Writer) error
Writes the header of a scrobbler log file to the given writer.