mirror of
https://github.com/mxpv/podsync.git
synced 2024-05-11 05:55:04 +00:00
fix: correct enclosure type on custom format
This commit is contained in:
@@ -50,8 +50,8 @@ vimeo = [ # Multiple keys will be rotated.
|
||||
# How often query for updates, examples: "60m", "4h", "2h45m"
|
||||
update_period = "12h"
|
||||
|
||||
quality = "high" # or "low"
|
||||
format = "video" # or: "audio", "custom"
|
||||
quality = "high" # "high" or "low"
|
||||
format = "video" # "audio", "video" or "custom"
|
||||
# When format = "custom"
|
||||
# YouTubeDL format parameter and result file extension
|
||||
custom_format = { youtube_dl_format = "bestaudio[ext=m4a]", extension = "m4a" }
|
||||
|
||||
@@ -133,6 +133,10 @@ func Build(_ctx context.Context, feed *model.Feed, cfg *Config, hostname string)
|
||||
if feed.Format == model.FormatAudio {
|
||||
enclosureType = itunes.MP3
|
||||
}
|
||||
if feed.Format == model.FormatCustom {
|
||||
enclosureType = EnclosureFromExtension(cfg)
|
||||
}
|
||||
|
||||
|
||||
var (
|
||||
episodeName = EpisodeName(cfg, episode)
|
||||
@@ -164,9 +168,32 @@ func EpisodeName(feedConfig *Config, episode *model.Episode) string {
|
||||
ext := "mp4"
|
||||
if feedConfig.Format == model.FormatAudio {
|
||||
ext = "mp3"
|
||||
} else if feedConfig.Format == model.FormatCustom {
|
||||
}
|
||||
if feedConfig.Format == model.FormatCustom {
|
||||
ext = feedConfig.CustomFormat.Extension
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s.%s", episode.ID, ext)
|
||||
}
|
||||
|
||||
func EnclosureFromExtension(feedConfig *Config) itunes.EnclosureType {
|
||||
ext := feedConfig.CustomFormat.Extension
|
||||
// Use switch on the day variable.
|
||||
switch {
|
||||
case ext == "m4a":
|
||||
return itunes.M4A
|
||||
case ext == "m4v":
|
||||
return itunes.M4V
|
||||
case ext == "mp4":
|
||||
return itunes.MP4
|
||||
case ext == "mp3":
|
||||
return itunes.MP3
|
||||
case ext == "mov":
|
||||
return itunes.MOV
|
||||
case ext == "pdf":
|
||||
return itunes.PDF
|
||||
case ext == "epub":
|
||||
return itunes.EPUB
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
@@ -21,6 +21,21 @@ const (
|
||||
FormatCustom = Format("custom")
|
||||
)
|
||||
|
||||
// Format to convert episode when downloading episodes
|
||||
type Enclosure struct {
|
||||
// ID of episode
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
Thumbnail string `json:"thumbnail"`
|
||||
Duration int64 `json:"duration"`
|
||||
VideoURL string `json:"video_url"`
|
||||
PubDate time.Time `json:"pub_date"`
|
||||
Size int64 `json:"size"`
|
||||
Order string `json:"order"`
|
||||
Status EpisodeStatus `json:"status"` // Disk status
|
||||
}
|
||||
|
||||
// Playlist sorting style
|
||||
type Sorting string
|
||||
|
||||
|
||||
@@ -197,7 +197,8 @@ func (dl *YoutubeDl) Download(ctx context.Context, feedConfig *feed.Config, epis
|
||||
ext := "mp4"
|
||||
if feedConfig.Format == model.FormatAudio {
|
||||
ext = "mp3"
|
||||
} else if feedConfig.Format == model.FormatCustom {
|
||||
}
|
||||
if feedConfig.Format == model.FormatCustom {
|
||||
ext = feedConfig.CustomFormat.Extension
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user