Skip to content

Commit

Permalink
Removing prefer-single-format in preparation for yt-dlp transition
Browse files Browse the repository at this point in the history
  • Loading branch information
boggydigital committed Dec 11, 2024
1 parent ce50193 commit 96e383a
Show file tree
Hide file tree
Showing 26 changed files with 165 additions and 283 deletions.
9 changes: 0 additions & 9 deletions cli-commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ add-channel
auto-refresh
auto-download
download-policy={^playlist-download-policies}
prefer-single-format
expand
force

Expand All @@ -20,7 +19,6 @@ add-playlist
auto-refresh
auto-download
download-policy={^playlist-download-policies}
prefer-single-format
expand
force

Expand All @@ -30,7 +28,6 @@ add-video
download-queue
ended
reason={^video-ended-reasons}
prefer-single-format
source
force

Expand All @@ -41,7 +38,6 @@ cleanup-ended-videos

download-video
video-id^*
prefer-single-format
source
force

Expand Down Expand Up @@ -75,7 +71,6 @@ get-video-metadata
migrate

process-queue
prefer-single-format
force

queue-channels-downloads
Expand All @@ -90,15 +85,13 @@ remove-channel
channel-id^*
auto-refresh
auto-download
prefer-single-format
expand
force

remove-playlist
playlist-id^*
auto-refresh
auto-download
prefer-single-format
expand
force

Expand All @@ -108,7 +101,6 @@ remove-videos
download-queue
progress
ended
prefer-single-format
source
force

Expand All @@ -121,7 +113,6 @@ serve
stderr$

sync
prefer-single-format
force

test-dependencies
Expand Down
16 changes: 5 additions & 11 deletions cli/add_channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ func AddChannelHandler(u *url.URL) error {

channelId := q.Get("channel-id")
options := &ChannelOptions{
AutoRefresh: q.Has("auto-refresh"),
AutoDownload: q.Has("auto-download"),
DownloadPolicy: data.ParseDownloadPolicy(q.Get("download-policy")),
PreferSingleFormat: q.Has("prefer-single-format"),
Expand: q.Has("expand"),
Force: q.Has("force"),
AutoRefresh: q.Has("auto-refresh"),
AutoDownload: q.Has("auto-download"),
DownloadPolicy: data.ParseDownloadPolicy(q.Get("download-policy")),
Expand: q.Has("expand"),
Force: q.Has("force"),
}

return AddChannel(nil, channelId, options)
Expand Down Expand Up @@ -60,11 +59,6 @@ func AddChannel(rdx kevlar.WriteableRedux, channelId string, opt *ChannelOptions
channelId: {data.TrueValue},
}
}
if opt.PreferSingleFormat {
propertyValues[data.ChannelPreferSingleFormatProperty] = map[string][]string{
channelId: {data.TrueValue},
}
}

for property, idValues := range propertyValues {
if err := rdx.BatchAddValues(property, idValues); err != nil {
Expand Down
16 changes: 5 additions & 11 deletions cli/add_playlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ func AddPlaylistHandler(u *url.URL) error {

playlistId := q.Get("playlist-id")
options := &PlaylistOptions{
AutoRefresh: q.Has("auto-refresh"),
AutoDownload: q.Has("auto-download"),
DownloadPolicy: data.ParseDownloadPolicy(q.Get("download-policy")),
PreferSingleFormat: q.Has("prefer-single-format"),
Expand: q.Has("expand"),
Force: q.Has("force"),
AutoRefresh: q.Has("auto-refresh"),
AutoDownload: q.Has("auto-download"),
DownloadPolicy: data.ParseDownloadPolicy(q.Get("download-policy")),
Expand: q.Has("expand"),
Force: q.Has("force"),
}

return AddPlaylist(nil, playlistId, options)
Expand Down Expand Up @@ -66,11 +65,6 @@ func AddPlaylist(rdx kevlar.WriteableRedux, playlistId string, opt *PlaylistOpti
playlistId: {data.TrueValue},
}
}
if opt.PreferSingleFormat {
propertyValues[data.PlaylistPreferSingleFormatProperty] = map[string][]string{
playlistId: {data.TrueValue},
}
}

for property, idValues := range propertyValues {
if err := rdx.BatchAddValues(property, idValues); err != nil {
Expand Down
18 changes: 6 additions & 12 deletions cli/add_video.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ func AddVideoHandler(u *url.URL) error {

videoId := q.Get("video-id")
options := &VideoOptions{
Favorite: q.Has("favorite"),
DownloadQueue: q.Has("download-queue"),
Ended: q.Has("ended"),
Reason: data.ParseVideoEndedReason(q.Get("reason")),
Source: q.Get("source"),
PreferSingleFormat: q.Has("prefer-single-format"),
Force: q.Has("force"),
Favorite: q.Has("favorite"),
DownloadQueue: q.Has("download-queue"),
Ended: q.Has("ended"),
Reason: data.ParseVideoEndedReason(q.Get("reason")),
Source: q.Get("source"),
Force: q.Has("force"),
}

return AddVideo(nil, videoId, options)
Expand Down Expand Up @@ -72,11 +71,6 @@ func AddVideo(rdx kevlar.WriteableRedux, videoId string, opt *VideoOptions) erro
videoId: {opt.Source},
}
}
if opt.PreferSingleFormat {
propertyValues[data.VideoPreferSingleFormatProperty] = map[string][]string{
videoId: {data.TrueValue},
}
}
if opt.Force {
propertyValues[data.VideoForcedDownloadProperty] = map[string][]string{
videoId: {data.TrueValue},
Expand Down
24 changes: 11 additions & 13 deletions cli/channel_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@ package cli
import "github.com/boggydigital/yet/data"

type ChannelOptions struct {
Playlists bool
AutoRefresh bool
AutoDownload bool
DownloadPolicy data.DownloadPolicy
PreferSingleFormat bool
Expand bool
Force bool
Playlists bool
AutoRefresh bool
AutoDownload bool
DownloadPolicy data.DownloadPolicy
Expand bool
Force bool
}

func DefaultChannelOptions() *ChannelOptions {
return &ChannelOptions{
AutoRefresh: false,
AutoDownload: false,
DownloadPolicy: data.Recent,
PreferSingleFormat: true,
Expand: false,
Force: false,
AutoRefresh: false,
AutoDownload: false,
DownloadPolicy: data.Recent,
Expand: false,
Force: false,
}
}
7 changes: 3 additions & 4 deletions cli/download_video.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ func DownloadVideoHandler(u *url.URL) error {

videoId := q.Get("video-id")
options := &VideoOptions{
PreferSingleFormat: q.Has("prefer-single-format"),
Force: q.Has("force"),
Source: q.Get("source"),
Force: q.Has("force"),
Source: q.Get("source"),
}

return DownloadVideo(nil, videoId, options)
Expand Down Expand Up @@ -137,7 +136,7 @@ func downloadVideo(
if err := downloadSingleFormat(dl, relFilename, sourceFormat, videoPage.PlayerUrl, options.Force); err != nil {
return err
}
} else if yeti.GetBinary(yeti.FFMpegBin) == "" || options.PreferSingleFormat {
} else if yeti.GetBinary(yeti.FFMpegBin) == "" {
if err := downloadSingleFormat(dl, relFilename, videoPage.BestFormat(), videoPage.PlayerUrl, options.Force); err != nil {
return err
}
Expand Down
22 changes: 10 additions & 12 deletions cli/playlist_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,19 @@ package cli
import "github.com/boggydigital/yet/data"

type PlaylistOptions struct {
AutoRefresh bool
AutoDownload bool
DownloadPolicy data.DownloadPolicy
PreferSingleFormat bool
Expand bool
Force bool
AutoRefresh bool
AutoDownload bool
DownloadPolicy data.DownloadPolicy
Expand bool
Force bool
}

func DefaultPlaylistOptions() *PlaylistOptions {
return &PlaylistOptions{
AutoRefresh: false,
AutoDownload: false,
DownloadPolicy: data.Recent,
PreferSingleFormat: true,
Expand: false,
Force: false,
AutoRefresh: false,
AutoDownload: false,
DownloadPolicy: data.Recent,
Expand: false,
Force: false,
}
}
6 changes: 1 addition & 5 deletions cli/process_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ func ProcessQueueHandler(u *url.URL) error {
q := u.Query()

options := &VideoOptions{
// TODO: remove this if better options are available
// (temporary?) workaround - force single format for all videos
// to mitigate new visitorData, poToken requirements at the cost of video quality
PreferSingleFormat: true, //q.Has("prefer-single-format"),
Force: q.Has("force"),
Force: q.Has("force"),
}

return ProcessQueue(nil, options)
Expand Down
12 changes: 4 additions & 8 deletions cli/remove_channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ func RemoveChannelHandler(u *url.URL) error {

channelId := q.Get("channel-id")
options := &ChannelOptions{
AutoRefresh: q.Has("auto-refresh"),
AutoDownload: q.Has("auto-download"),
PreferSingleFormat: q.Has("prefer-single-format"),
Expand: q.Has("expand"),
Force: q.Has("force"),
AutoRefresh: q.Has("auto-refresh"),
AutoDownload: q.Has("auto-download"),
Expand: q.Has("expand"),
Force: q.Has("force"),
}

return RemoveChannel(nil, channelId, options)
Expand Down Expand Up @@ -51,9 +50,6 @@ func RemoveChannel(rdx kevlar.WriteableRedux, channelId string, opt *ChannelOpti
if opt.Expand {
propertyKeys[data.ChannelExpandProperty] = channelId
}
if opt.PreferSingleFormat {
propertyKeys[data.ChannelPreferSingleFormatProperty] = channelId
}

for property, key := range propertyKeys {
if err := rdx.CutKeys(property, key); err != nil {
Expand Down
12 changes: 4 additions & 8 deletions cli/remove_playlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ func RemovePlaylistHandler(u *url.URL) error {

playlistId := q.Get("playlist-id")
options := &PlaylistOptions{
AutoRefresh: q.Has("auto-refresh"),
AutoDownload: q.Has("auto-download"),
PreferSingleFormat: q.Has("prefer-single-format"),
Expand: q.Has("expand"),
Force: q.Has("force"),
AutoRefresh: q.Has("auto-refresh"),
AutoDownload: q.Has("auto-download"),
Expand: q.Has("expand"),
Force: q.Has("force"),
}

return RemovePlaylist(nil, playlistId, options)
Expand Down Expand Up @@ -57,9 +56,6 @@ func RemovePlaylist(rdx kevlar.WriteableRedux, playlistId string, opt *PlaylistO
if opt.Expand {
propertyKeys[data.PlaylistExpandProperty] = playlistId
}
if opt.PreferSingleFormat {
propertyKeys[data.PlaylistPreferSingleFormatProperty] = playlistId
}

for property, key := range propertyKeys {
if err := rdx.CutKeys(property, key); err != nil {
Expand Down
12 changes: 4 additions & 8 deletions cli/remove_videos.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ func RemoveVideosHandler(u *url.URL) error {

videoId := q.Get("video-id")
options := &VideoOptions{
DownloadQueue: q.Has("download-queue"),
Progress: q.Has("progress"),
Ended: q.Has("ended"),
PreferSingleFormat: q.Has("prefer-single-format"),
Force: q.Has("force"),
DownloadQueue: q.Has("download-queue"),
Progress: q.Has("progress"),
Ended: q.Has("ended"),
Force: q.Has("force"),
}

return RemoveVideos(nil, videoId, options)
Expand Down Expand Up @@ -57,9 +56,6 @@ func RemoveVideos(rdx kevlar.WriteableRedux, videoId string, opt *VideoOptions)
if opt.Source != "" {
propertyKeys[data.VideoSourceProperty] = videoId
}
if opt.PreferSingleFormat {
propertyKeys[data.VideoPreferSingleFormatProperty] = videoId
}
if opt.Force {
propertyKeys[data.VideoForcedDownloadProperty] = videoId
}
Expand Down
6 changes: 1 addition & 5 deletions cli/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ func SyncHandler(u *url.URL) error {
q := u.Query()

options := &VideoOptions{
// TODO: remove this if better options are available
// (temporary?) workaround - force single format for all videos
// to mitigate new visitorData, poToken requirements at the cost of video quality
PreferSingleFormat: true, //q.Has("prefer-single-format"),
Force: q.Has("Force"),
Force: q.Has("Force"),
}
return Sync(nil, options)
}
Expand Down
1 change: 0 additions & 1 deletion cli/update_yt_dlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ func UpdateYtDlp(force bool) error {
}

ytDlpBinaryFilename := filepath.Join(ytDlpDir, ytDlpAsset)

if err := os.Chmod(ytDlpBinaryFilename, 0555); err != nil {
return uyda.EndWithError(err)
}
Expand Down
Loading

0 comments on commit 96e383a

Please sign in to comment.