Skip to content

Commit

Permalink
Support cover art quality
Browse files Browse the repository at this point in the history
  • Loading branch information
mxpv committed Oct 4, 2020
1 parent 0ce6e99 commit 3572e14
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 29 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ vimeo = [ # Multiple keys will be rotated.
update_period = "12h" # How often query for updates, examples: "60m", "4h", "2h45m"
quality = "high" # or "low"
format = "video" # or "audio"
# custom = { cover_art = "{IMAGE_URL}}", category = "TV", subcategories = ["Documentary", "Tech News"], explicit = true, lang = "en" } # Optional feed customizations
# custom.cover_art_quality use "high" or "low" to special cover image quality from channel cover default is equal with "quality" and disable when custom.cover_art was set.
# custom = { cover_art = "{IMAGE_URL}}", cover_art_quality = "high", category = "TV", subcategories = ["Documentary", "Tech News"], explicit = true, lang = "en" } # Optional feed customizations
# max_height = "720" # Optional maximal height of video, example: 720, 1080, 1440, 2160, ...
# cron_schedule = "@every 12h" # Optional cron expression format. If set then overwrite 'update_period'. See details below
# filters = { title = "regex for title here", not_title = "regex for negative title match", description = "...", not_description = "..." } # Optional Golang regexp format. If set, then only download matching episodes.
Expand Down
2 changes: 1 addition & 1 deletion pkg/builder/youtube.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func (yt *YouTubeBuilder) queryFeed(ctx context.Context, feed *model.Feed, info
feed.Description = fmt.Sprintf("%s (%s)", feed.Title, feed.PubDate)
}

feed.CoverArt = yt.selectThumbnail(thumbnails, feed.Quality, "")
feed.CoverArt = yt.selectThumbnail(thumbnails, feed.CoverArtQuality, "")

return nil
}
Expand Down
21 changes: 13 additions & 8 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,15 @@ type Filters struct {
}

type Custom struct {
CoverArt string `toml:"cover_art"`
Category string `toml:"category"`
Subcategories []string `toml:"subcategories"`
Explicit bool `toml:"explicit"`
Language string `toml:"lang"`
Author string `toml:"author"`
Title string `toml:"title"`
Description string `toml:"description"`
CoverArt string `toml:"cover_art"`
CoverArtQuality model.Quality `toml:"cover_art_quality"`
Category string `toml:"category"`
Subcategories []string `toml:"subcategories"`
Explicit bool `toml:"explicit"`
Language string `toml:"lang"`
Author string `toml:"author"`
Title string `toml:"title"`
Description string `toml:"description"`
}

type Server struct {
Expand Down Expand Up @@ -207,6 +208,10 @@ func (c *Config) applyDefaults(configPath string) {
feed.Quality = model.DefaultQuality
}

if feed.Custom.CoverArtQuality == "" {
feed.Custom.CoverArtQuality = model.DefaultQuality
}

if feed.Format == "" {
feed.Format = model.DefaultFormat
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ self_update = true
quality = "low"
filters = { title = "regex for title here" }
clean = { keep_last = 10 }
custom = { cover_art = "http://img", category = "TV", subcategories = ["1", "2"], explicit = true, lang = "en" }
custom = { cover_art = "http://img", cover_art_quality = "high", category = "TV", subcategories = ["1", "2"], explicit = true, lang = "en" }
`
path := setup(t, file)
defer os.Remove(path)
Expand Down Expand Up @@ -72,6 +72,7 @@ self_update = true
assert.EqualValues(t, 10, feed.Clean.KeepLast)

assert.EqualValues(t, "http://img", feed.Custom.CoverArt)
assert.EqualValues(t, "high", feed.Custom.CoverArtQuality)
assert.EqualValues(t, "TV", feed.Custom.Category)
assert.True(t, feed.Custom.Explicit)
assert.EqualValues(t, "en", feed.Custom.Language)
Expand Down Expand Up @@ -128,6 +129,7 @@ data_dir = "/data"
assert.EqualValues(t, feed.UpdatePeriod, Duration{model.DefaultUpdatePeriod})
assert.EqualValues(t, feed.PageSize, 50)
assert.EqualValues(t, feed.Quality, "high")
assert.EqualValues(t, feed.Custom.CoverArtQuality, "high")
assert.EqualValues(t, feed.Format, "video")
}

Expand Down
37 changes: 19 additions & 18 deletions pkg/model/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,25 @@ type Episode struct {
}

type Feed struct {
ID string `json:"feed_id"`
ItemID string `json:"item_id"`
LinkType Type `json:"link_type"` // Either group, channel or user
Provider Provider `json:"provider"` // Youtube or Vimeo
CreatedAt time.Time `json:"created_at"`
LastAccess time.Time `json:"last_access"`
ExpirationTime time.Time `json:"expiration_time"`
Format Format `json:"format"`
Quality Quality `json:"quality"`
PageSize int `json:"page_size"`
CoverArt string `json:"cover_art"`
Title string `json:"title"`
Description string `json:"description"`
PubDate time.Time `json:"pub_date"`
Author string `json:"author"`
ItemURL string `json:"item_url"` // Platform specific URL
Episodes []*Episode `json:"-"` // Array of episodes
UpdatedAt time.Time `json:"updated_at"`
ID string `json:"feed_id"`
ItemID string `json:"item_id"`
LinkType Type `json:"link_type"` // Either group, channel or user
Provider Provider `json:"provider"` // Youtube or Vimeo
CreatedAt time.Time `json:"created_at"`
LastAccess time.Time `json:"last_access"`
ExpirationTime time.Time `json:"expiration_time"`
Format Format `json:"format"`
Quality Quality `json:"quality"`
CoverArtQuality Quality `json:"cover_art_quality"`
PageSize int `json:"page_size"`
CoverArt string `json:"cover_art"`
Title string `json:"title"`
Description string `json:"description"`
PubDate time.Time `json:"pub_date"`
Author string `json:"author"`
ItemURL string `json:"item_url"` // Platform specific URL
Episodes []*Episode `json:"-"` // Array of episodes
UpdatedAt time.Time `json:"updated_at"`
}

type EpisodeStatus string
Expand Down

0 comments on commit 3572e14

Please sign in to comment.