Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/share #367

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ password can then be changed from the web interface
| `GONIC_PODCAST_PURGE_AGE` | `-podcast-purge-age` | **optional** age (in days) to purge podcast episodes if not accessed |
| `GONIC_GENRE_SPLIT` | `-genre-split` | **optional** a string or character to split genre tags on for multi-genre support (eg. `;`) |
| `GONIC_EXCLUDE_PATTERN` | `-exclude-pattern` | **optional** files matching this regex pattern will not be imported |
| `GONIC_SHARE_UI_URL` | `-share-ui-url` | **optional** URL of the Web interface which support sharing |

## screenshots

Expand Down
3 changes: 3 additions & 0 deletions cmd/gonic/gonic.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ func main() {

confExcludePatterns := set.String("exclude-pattern", "", "regex pattern to exclude files from scan (optional)")

confShareUIURL := set.String("share-ui-url", "", "Shares user interface url")

if _, err := regexp.Compile(*confExcludePatterns); err != nil {
log.Fatalf("invalid exclude pattern: %v\n", err)
}
Expand Down Expand Up @@ -147,6 +149,7 @@ func main() {
GenreSplit: *confGenreSplit,
HTTPLog: *confHTTPLog,
JukeboxEnabled: *confJukeboxEnabled,
ShareUIURL: *confShareUIURL,
})
if err != nil {
log.Panicf("error creating server: %v\n", err)
Expand Down
9 changes: 9 additions & 0 deletions db/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func (db *DB) Migrate(ctx MigrationContext) error {
construct(ctx, "202211111057", migratePlaylistsQueuesToFullID),
construct(ctx, "202304221528", migratePlaylistsToM3U),
construct(ctx, "202305301718", migratePlayCountToLength),
construct(ctx, "202309051209", migrateShare),
}

return gormigrate.
Expand Down Expand Up @@ -538,3 +539,11 @@ func migratePlayCountToLength(tx *gorm.DB, _ MigrationContext) error {

return nil
}

func migrateShare(tx *gorm.DB, _ MigrationContext) error {
return tx.AutoMigrate(
Share{},
ShareEntry{},
).
Error
}
22 changes: 21 additions & 1 deletion db/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ type Play struct {
AlbumID int `gorm:"not null; index" sql:"default: null; type:int REFERENCES albums(id) ON DELETE CASCADE"`
Time time.Time `sql:"default: null"`
Count int
Length int
Length int
}

type Album struct {
Expand Down Expand Up @@ -429,3 +429,23 @@ type InternetRadioStation struct {
func (ir *InternetRadioStation) SID() *specid.ID {
return &specid.ID{Type: specid.InternetRadioStation, Value: ir.ID}
}

type Share struct {
ID int `gorm:"primary_key"`
Title string
UserID int `sql:"default: null; type:int REFERENCES users(id) ON DELETE CASCADE"`
CreatedAt time.Time
ExpiresAt time.Time
LastVisitedAt time.Time
VisitCount int
Description string
Secret string
Download bool
Entries []string `gorm:"-"`
}

type ShareEntry struct {
ID int `gorm:"primary_key"`
ShareID int `sql:"default: null; type:int REFERENCES shares(id) ON DELETE CASCADE"`
Entry string
}
2 changes: 2 additions & 0 deletions server/ctrlsubsonic/ctrl.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"go.senan.xyz/gonic/server/ctrlbase"
"go.senan.xyz/gonic/server/ctrlsubsonic/params"
"go.senan.xyz/gonic/server/ctrlsubsonic/spec"
"go.senan.xyz/gonic/share"
"go.senan.xyz/gonic/transcode"
)

Expand Down Expand Up @@ -50,6 +51,7 @@ type Controller struct {
Podcasts *podcasts.Podcasts
Transcoder transcode.Transcoder
LastFMClient *lastfm.Client
Shares *share.Share
}

type metaResponse struct {
Expand Down
Loading
Loading