From fe884799c7a804985efc5b0c8038e615f8438d80 Mon Sep 17 00:00:00 2001 From: Justin Hawkins Date: Sat, 11 Nov 2023 13:07:26 +1030 Subject: [PATCH] Add an option to start with some test downloads queued --- main.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/main.go b/main.go index 19a8207..27be245 100644 --- a/main.go +++ b/main.go @@ -44,7 +44,10 @@ func main() { log.Printf("Starting gropple %s - https://github.com/tardisx/gropple", versionInfo.GetInfo().CurrentVersion) var configPath string + var testDownloads bool flag.StringVar(&configPath, "config-path", "", "path to config file") + flag.BoolVar(&testDownloads, "test-downloads", false, "queue up several downloads for testing purposes") + flag.Parse() configService = &config.ConfigService{} @@ -74,6 +77,31 @@ func main() { // create the download manager dm = &download.Manager{MaxPerDomain: configService.Config.Server.MaximumActiveDownloads} + if testDownloads { + dm.AddDownload(download.NewDownload("https://www.youtube.com/watch?v=tyixMpuGEL8", configService.Config)) + dm.AddDownload(download.NewDownload("https://www.youtube.com/watch?v=VnxbkH_3E_4", configService.Config)) + dm.AddDownload(download.NewDownload("https://www.youtube.com/watch?v=VStscvYLYLs", configService.Config)) + dm.AddDownload(download.NewDownload("https://www.youtube.com/watch?v=vYMiSz-WlEY", configService.Config)) + + dm.AddDownload(download.NewDownload("https://www.gamespot.com/videos/survival-fps-how-metro-2033-solidified-a-subgenre/2300-6408243/", configService.Config)) + dm.AddDownload(download.NewDownload("https://www.gamespot.com/videos/dirt-3-right-back-where-you-started-gameplay-movie/2300-6314712/", configService.Config)) + dm.AddDownload(download.NewDownload("https://www.gamespot.com/videos/the-b-list-driver-san-francisco/2300-6405593/", configService.Config)) + + dm.AddDownload(download.NewDownload("https://www.imdb.com/video/vi1914750745/?listId=ls053181649&ref_=hm_hp_i_hero-video-1_1", configService.Config)) + dm.AddDownload(download.NewDownload("https://www.imdb.com/video/vi3879585561/?listId=ls053181649&ref_=vp_pl_ap_6", configService.Config)) + dm.AddDownload(download.NewDownload("https://www.imdb.com/video/vi54445849/?listId=ls053181649&ref_=vp_nxt_btn", configService.Config)) + + if len(configService.Config.DownloadProfiles) == 0 { + panic("no profiles installed - cannot add test downloads") + } + profile := configService.Config.ProfileCalled(configService.Config.DownloadProfiles[0].Name) + for i := range dm.Downloads { + // set the profile and queue it + dm.Downloads[i].DownloadProfile = *profile + dm.Queue(dm.Downloads[i]) + } + } + r := mux.NewRouter() r.HandleFunc("/", homeHandler) r.HandleFunc("/static/{filename}", staticHandler)