-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skips download if file exists (unless overridden)
New Feature: If a episode has already been downloaded, then it won't be downloaded when the program runs again - it will be skipped. Previously downloaded episodes are matched based on the file size and the file name. If a download already exists, but the size of the file is different from what is being downloaded, then it is considered to be an incomplete download and will be overwritten (resuming downloads is not supported at this time). This behavior can be overwritten using the -o (or -overwrite) flag, which will cause an existing download to be overwritten regardless of whether or not the download completed fully on a previous download attempt.
- Loading branch information
Showing
11 changed files
with
158 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
using Fclp; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace SimpleTv.Downloader | ||
{ | ||
public static class Arguments | ||
{ | ||
public static FluentCommandLineParser<Configuration> Setup() | ||
{ | ||
var p = new FluentCommandLineParser<Configuration>(); | ||
|
||
p.Setup(arg => arg.Username) | ||
.As('u', "username") | ||
.WithDescription("Username for logging into Simple.Tv") | ||
.Required(); | ||
|
||
p.Setup(arg => arg.Password) | ||
.As('p', "password") | ||
.WithDescription("Password for logging into Simple.Tv") | ||
.Required(); | ||
|
||
// Later on, -d / -dryrun will be used to do a dry run (parsing without downloading) | ||
|
||
p.Setup(arg => arg.ShowIncludeFilter) | ||
.As('i', "includeShows") | ||
.WithDescription("[optional] Type in show(s) to include. Wildcards accepted.") | ||
.SetDefault("*"); | ||
|
||
p.Setup(arg => arg.ShowExcludeFilter) | ||
.As('x', "excludeShows") | ||
.WithDescription("[optional] Type in show(s) to exclude. Wildcards accepted.") | ||
.SetDefault(string.Empty); | ||
|
||
p.Setup(arg => arg.ServerIncludeFilter) | ||
.As('s', "includeServers") | ||
.WithDescription("[optional] Type in media server(s) to include. Wildcards accepted.") | ||
.SetDefault("*"); | ||
|
||
p.Setup(arg => arg.ServerExcludeFilter) | ||
.As('e', "excludeServers") | ||
.WithDescription("[optional] Type in media server(s) to exclude. Wildcards accepted.") | ||
.SetDefault(string.Empty); | ||
|
||
p.Setup(arg => arg.DownloadFolder) | ||
.As('f', "downloadFolder") | ||
.WithDescription("[optional] Folder to place downloaded recordings in. Defaults to current working directory.") | ||
.SetDefault(Directory.GetCurrentDirectory()); | ||
|
||
p.Setup(arg => arg.FolderFormat) | ||
.As('t', "folderformat") | ||
.WithDescription("[optional] The folder format for saving the recording, relative to the downloadfolder. Defaults to Plex format defined at https://support.plex.tv/hc/en-us/articles/200220687-Naming-Series-Season-Based-TV-Shows") | ||
.SetDefault("{ShowName}\\Season {SeasonNumber00}"); | ||
|
||
p.Setup(arg => arg.FilenameFormat) | ||
.As('n', "filenameformat") | ||
.WithDescription("[optional] The filename format for saving the recording. Defaults to Plex format defined at https://support.plex.tv/hc/en-us/articles/200220687-Naming-Series-Season-Based-TV-Shows") | ||
.SetDefault("{ShowName} - S{SeasonNumber00}E{EpisodeNumber00} - {EpisodeName}.mp4"); | ||
|
||
p.Setup(arg => arg.OverwriteExistingDownloads) | ||
.As('o', "overwrite") | ||
.WithDescription("[optional] Will overwrite previously downloaded episodes. If you do not set this, episodes that have previously been downloaded will be skipped.") | ||
.SetDefault(false); | ||
|
||
p.Setup(arg => arg.LogHttpCalls) | ||
.As('l', "logHttpCalls") | ||
.WithDescription("[optional] Will save a log of all http calls, helpful for debugging errors") | ||
.SetDefault(false); | ||
|
||
p.Setup(arg => arg.Reboot) | ||
.As('r', "reboot") | ||
.WithDescription("Used to reboot Simple.TV DVRs. Can be used with -s and -t.") | ||
.SetDefault(false); | ||
|
||
p.SetupHelp("?", "help") | ||
.WithHeader(string.Format( | ||
"SimpleTV Downloader\n" + | ||
"Version {0}\n" + | ||
"\n" + | ||
"SimpleTV Downloader can download your Simple.Tv recordings. \r\n" + | ||
"Usage:\r\n" + | ||
"\t{1} -u [email protected] -p \"P@ssw0Rd\" -d c:\\tvshows -i \"NCIS*\"", | ||
Assembly.GetExecutingAssembly().GetName().Version, | ||
Path.GetFileName(Assembly.GetEntryAssembly().Location) | ||
)) | ||
.Callback(text => Console.WriteLine(text)); | ||
|
||
return p; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,11 +10,9 @@ namespace SimpleTv.Downloader | |
{ | ||
class Program | ||
{ | ||
private static string execName = Path.GetFileName(System.Reflection.Assembly.GetEntryAssembly().Location); | ||
|
||
static void Main(string[] args) | ||
{ | ||
var p = SetupArguments(); | ||
var p = Arguments.Setup(); | ||
var result = p.Parse(args); | ||
if (result.HasErrors) | ||
{ | ||
|
@@ -55,82 +53,5 @@ static void Main(string[] args) | |
} | ||
} | ||
} | ||
|
||
public static FluentCommandLineParser<Configuration> SetupArguments() | ||
{ | ||
var p = new FluentCommandLineParser<Configuration>(); | ||
|
||
p.Setup(arg => arg.Username) | ||
.As('u', "username") | ||
.WithDescription("Username for logging into Simple.Tv") | ||
.Required(); | ||
|
||
p.Setup(arg => arg.Password) | ||
.As('p', "password") | ||
.WithDescription("Password for logging into Simple.Tv") | ||
.Required(); | ||
|
||
// Later on, -d / -dryrun will be used to do a dry run (parsing without downloading) | ||
|
||
p.Setup(arg => arg.ShowIncludeFilter) | ||
.As('i', "includeShows") | ||
.WithDescription("[optional] Type in show(s) to include. Wildcards accepted.") | ||
.SetDefault("*"); | ||
|
||
p.Setup(arg => arg.ShowExcludeFilter) | ||
.As('x', "excludeShows") | ||
.WithDescription("[optional] Type in show(s) to exclude. Wildcards accepted.") | ||
.SetDefault(string.Empty); | ||
|
||
p.Setup(arg => arg.ServerIncludeFilter) | ||
.As('s', "includeServers") | ||
.WithDescription("[optional] Type in media server(s) to include. Wildcards accepted.") | ||
.SetDefault("*"); | ||
|
||
p.Setup(arg => arg.ServerExcludeFilter) | ||
.As('e', "excludeServers") | ||
.WithDescription("[optional] Type in media server(s) to exclude. Wildcards accepted.") | ||
.SetDefault(string.Empty); | ||
|
||
p.Setup(arg => arg.DownloadFolder) | ||
.As('f', "downloadFolder") | ||
.WithDescription("[optional] Folder to place downloaded recordings in. Defaults to current working directory.") | ||
.SetDefault(Directory.GetCurrentDirectory()); | ||
|
||
p.Setup(arg => arg.FolderFormat) | ||
.As('t', "folderformat") | ||
.WithDescription("[optional] The folder format for saving the recording, relative to the downloadfolder. Defaults to Plex format defined at https://support.plex.tv/hc/en-us/articles/200220687-Naming-Series-Season-Based-TV-Shows") | ||
.SetDefault("{ShowName}\\Season {SeasonNumber00}"); | ||
|
||
p.Setup(arg => arg.FilenameFormat) | ||
.As('n', "filenameformat") | ||
.WithDescription("[optional] The filename format for saving the recording. Defaults to Plex format defined at https://support.plex.tv/hc/en-us/articles/200220687-Naming-Series-Season-Based-TV-Shows") | ||
.SetDefault("{ShowName} - S{SeasonNumber00}E{EpisodeNumber00} - {EpisodeName}.mp4"); | ||
|
||
p.Setup(arg => arg.LogHttpCalls) | ||
.As('l', "logHttpCalls") | ||
.WithDescription("[optional] Will save a log of all http calls, helpful for debugging errors") | ||
.SetDefault(false); | ||
|
||
p.Setup(arg => arg.Reboot) | ||
.As('r', "reboot") | ||
.WithDescription("Used to reboot Simple.TV DVRs. Can be used with -s and -t.") | ||
.SetDefault(false); | ||
|
||
p.SetupHelp("?", "help") | ||
.WithHeader(string.Format( | ||
"SimpleTV Downloader\n" + | ||
"Version {0}\n" + | ||
"\n" + | ||
"SimpleTV Downloader can download your Simple.Tv recordings. \r\n" + | ||
"Usage:\r\n" + | ||
"\t{1} -u [email protected] -p \"P@ssw0Rd\" -d c:\\tvshows -i \"NCIS*\"", | ||
Assembly.GetExecutingAssembly().GetName().Version, execName | ||
)) | ||
.Callback(text => Console.WriteLine(text)); | ||
|
||
return p; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace SimpleTv.Sdk.Models | ||
{ | ||
public class DownloadDetails | ||
{ | ||
public Episode Episode { get; set; } | ||
public bool FileExistsWithSameSize { get; set; } | ||
public Uri FullUriToVideo { get; set; } | ||
public long DownloadSize { get; set;} | ||
public string FilePathAndName { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters