mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-30 05:37:05 +02:00
scrobblerlog: use camelcase for constants
This commit is contained in:
parent
d51c97c648
commit
bcb1834994
3 changed files with 16 additions and 16 deletions
|
@ -45,16 +45,16 @@ import (
|
|||
type TZInfo string
|
||||
|
||||
const (
|
||||
TZ_UNKNOWN TZInfo = "UNKNOWN"
|
||||
TZ_UTC TZInfo = "UTC"
|
||||
TimezoneUnknown TZInfo = "UNKNOWN"
|
||||
TimezoneUTC TZInfo = "UTC"
|
||||
)
|
||||
|
||||
// L if listened at least 50% or S if skipped
|
||||
type Rating string
|
||||
|
||||
const (
|
||||
RATING_LISTENED Rating = "L"
|
||||
RATING_SKIPPED Rating = "S"
|
||||
RatingListened Rating = "L"
|
||||
RatingSkipped Rating = "S"
|
||||
)
|
||||
|
||||
// A single entry of a track in the scrobbler log file.
|
||||
|
@ -75,7 +75,7 @@ type ScrobblerLog struct {
|
|||
Client string
|
||||
Records []Record
|
||||
// Timezone to be used for timestamps in the log file,
|
||||
// if TZ is set to [TZ_UNKNOWN].
|
||||
// if TZ is set to [TimezoneUnknown].
|
||||
FallbackTimezone *time.Location
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ func (l *ScrobblerLog) Parse(data io.Reader, ignoreSkipped bool) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if ignoreSkipped && record.Rating == RATING_SKIPPED {
|
||||
if ignoreSkipped && record.Rating == RatingSkipped {
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ func (l ScrobblerLog) rowToRecord(row []string) (Record, error) {
|
|||
}
|
||||
|
||||
var timezone *time.Location = nil
|
||||
if l.TZ == TZ_UNKNOWN {
|
||||
if l.TZ == TimezoneUnknown {
|
||||
timezone = l.FallbackTimezone
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ func TestParser(t *testing.T) {
|
|||
result := scrobblerlog.ScrobblerLog{}
|
||||
err := result.Parse(data, false)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(scrobblerlog.TZ_UNKNOWN, result.TZ)
|
||||
assert.Equal(scrobblerlog.TimezoneUnknown, result.TZ)
|
||||
assert.Equal("Rockbox sansaclipplus $Revision$", result.Client)
|
||||
assert.Len(result.Records, 5)
|
||||
record1 := result.Records[0]
|
||||
|
@ -59,11 +59,11 @@ func TestParser(t *testing.T) {
|
|||
assert.Equal("Sevdanin rengi (sipacik) byMrTurkey", record1.TrackName)
|
||||
assert.Equal(5, record1.TrackNumber)
|
||||
assert.Equal(time.Duration(306*time.Second), record1.Duration)
|
||||
assert.Equal(scrobblerlog.RATING_LISTENED, record1.Rating)
|
||||
assert.Equal(scrobblerlog.RatingListened, record1.Rating)
|
||||
assert.Equal(time.Unix(1260342084, 0), record1.Timestamp)
|
||||
assert.Equal(mbtypes.MBID(""), record1.MusicBrainzRecordingID)
|
||||
record4 := result.Records[3]
|
||||
assert.Equal(scrobblerlog.RATING_SKIPPED, record4.Rating)
|
||||
assert.Equal(scrobblerlog.RatingSkipped, record4.Rating)
|
||||
assert.Equal(mbtypes.MBID("385ba9e9-626d-4750-a607-58e541dca78e"),
|
||||
record4.MusicBrainzRecordingID)
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ func TestParserIgnoreSkipped(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
assert.Len(result.Records, 4)
|
||||
record4 := result.Records[3]
|
||||
assert.Equal(scrobblerlog.RATING_LISTENED, record4.Rating)
|
||||
assert.Equal(scrobblerlog.RatingListened, record4.Rating)
|
||||
assert.Equal(mbtypes.MBID("1262beaf-19f8-4534-b9ed-7eef9ca8e83f"),
|
||||
record4.MusicBrainzRecordingID)
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ func TestAppend(t *testing.T) {
|
|||
data := make([]byte, 0, 10)
|
||||
buffer := bytes.NewBuffer(data)
|
||||
log := scrobblerlog.ScrobblerLog{
|
||||
TZ: scrobblerlog.TZ_UNKNOWN,
|
||||
TZ: scrobblerlog.TimezoneUnknown,
|
||||
Client: "Rockbox foo $Revision$",
|
||||
}
|
||||
records := []scrobblerlog.Record{
|
||||
|
@ -111,7 +111,7 @@ func TestAppend(t *testing.T) {
|
|||
TrackName: "Reign",
|
||||
TrackNumber: 1,
|
||||
Duration: 271 * time.Second,
|
||||
Rating: scrobblerlog.RATING_LISTENED,
|
||||
Rating: scrobblerlog.RatingListened,
|
||||
Timestamp: time.Unix(1699572072, 0),
|
||||
MusicBrainzRecordingID: mbtypes.MBID("b59cf4e7-caee-4019-a844-79d2c58d4dff"),
|
||||
},
|
||||
|
@ -139,7 +139,7 @@ func TestReadHeader(t *testing.T) {
|
|||
log := scrobblerlog.ScrobblerLog{}
|
||||
err := log.ReadHeader(reader)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, log.TZ, scrobblerlog.TZ_UNKNOWN)
|
||||
assert.Equal(t, log.TZ, scrobblerlog.TimezoneUnknown)
|
||||
assert.Equal(t, log.Client, "Rockbox sansaclipplus $Revision$")
|
||||
assert.Empty(t, log.Records)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue