mirror of
https://git.sr.ht/~phw/scotty
synced 2025-05-31 10:58:35 +02:00
Renamed listenbrainz.Archive to listenbrainz.ExportArchive
This commit is contained in:
parent
8462b9395e
commit
cf5319309a
2 changed files with 8 additions and 8 deletions
|
@ -69,7 +69,7 @@ func (b *ListenBrainzArchiveBackend) ExportListens(
|
|||
},
|
||||
}
|
||||
|
||||
archive, err := listenbrainz.OpenArchive(b.filePath)
|
||||
archive, err := listenbrainz.OpenExportArchive(b.filePath)
|
||||
if err != nil {
|
||||
p.Export.Abort()
|
||||
progress <- p
|
||||
|
|
|
@ -38,27 +38,27 @@ import (
|
|||
//
|
||||
// The export contains the user's listen history, favorite tracks and
|
||||
// user information.
|
||||
type Archive struct {
|
||||
type ExportArchive struct {
|
||||
backend archive.Archive
|
||||
}
|
||||
|
||||
// Open a ListenBrainz archive from file path.
|
||||
func OpenArchive(path string) (*Archive, error) {
|
||||
func OpenExportArchive(path string) (*ExportArchive, error) {
|
||||
backend, err := archive.OpenArchive(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Archive{backend: backend}, nil
|
||||
return &ExportArchive{backend: backend}, nil
|
||||
}
|
||||
|
||||
// Close the archive and release any resources.
|
||||
func (a *Archive) Close() error {
|
||||
func (a *ExportArchive) Close() error {
|
||||
return a.backend.Close()
|
||||
}
|
||||
|
||||
// Read the user information from the archive.
|
||||
func (a *Archive) UserInfo() (UserInfo, error) {
|
||||
func (a *ExportArchive) UserInfo() (UserInfo, error) {
|
||||
f, err := a.backend.OpenFile("user.json")
|
||||
if err != nil {
|
||||
return UserInfo{}, err
|
||||
|
@ -75,7 +75,7 @@ func (a *Archive) UserInfo() (UserInfo, error) {
|
|||
return userInfo, nil
|
||||
}
|
||||
|
||||
func (a *Archive) ListListenExports() ([]ListenExportFileInfo, error) {
|
||||
func (a *ExportArchive) ListListenExports() ([]ListenExportFileInfo, error) {
|
||||
re := regexp.MustCompile(`^listens/(\d{4})/(\d{1,2})\.jsonl$`)
|
||||
result := make([]ListenExportFileInfo, 0)
|
||||
|
||||
|
@ -109,7 +109,7 @@ func (a *Archive) ListListenExports() ([]ListenExportFileInfo, error) {
|
|||
|
||||
// Yields all listens from the archive that are newer than the given timestamp.
|
||||
// The listens are yielded in ascending order of their listened_at timestamp.
|
||||
func (a *Archive) IterListens(minTimestamp time.Time) iter.Seq2[Listen, error] {
|
||||
func (a *ExportArchive) IterListens(minTimestamp time.Time) iter.Seq2[Listen, error] {
|
||||
return func(yield func(Listen, error) bool) {
|
||||
files, err := a.ListListenExports()
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue