Skip to content

Commit

Permalink
2.1 - a quality update
Browse files Browse the repository at this point in the history
Added new quality options for download video and audio, this ranges from 144p to 4320p (8k) for video, and 64k-320k for audio. Best is still an option.
With 8k being an option, i moved it to the last 2 options because this is a crazy resolution to download in, so... don't complain to me if it eats your data usage.
Also, some videos use 21:9, 32:9 ratios, so keep that in mind when selecting a quality.
I plan on implementing a custom way of doing this later, but I don't see a reason at the moment (other than audio, for people who like to listen to 32k audio)

Re-enabled the tray icon... i forgot about it.

Also in this release:
Changed the args and output folder appending to the arg string.
Added a boolean for use hls for FFmpeg on reddit links.
  • Loading branch information
murrty1 authored Jul 23, 2019
1 parent 8a227af commit 42f3b9c
Show file tree
Hide file tree
Showing 10 changed files with 362 additions and 146 deletions.
8 changes: 7 additions & 1 deletion App.config
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@
<setting name="convertCustom" serializeAs="String">
<value />
</setting>
<setting name="videoQuality" serializeAs="String">
<value>0</value>
</setting>
<setting name="audioQuality" serializeAs="String">
<value>0</value>
</setting>
</youtube_dl_gui.Saved>
<youtube_dl_gui.Converter>
<setting name="detectFiletype" serializeAs="String">
Expand Down Expand Up @@ -207,7 +213,7 @@
<applicationSettings>
<youtube_dl_gui.Properties.Settings>
<setting name="appVersion" serializeAs="String">
<value>2.0</value>
<value>2.1</value>
</setting>
<setting name="stubVersion" serializeAs="String">
<value>1</value>
Expand Down
79 changes: 58 additions & 21 deletions Classes/Download.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,57 @@ class Download {
// 2 = Custom // Unsortable

/// <summary>
/// Built-in best quality for video downloads
/// Built-in video qualities
/// </summary>
public static string bestVideo = " -f \"bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best\"";
public static string[] videoQualities = {
" -f \"bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best\"", // 0 best
" -f \"bestvideo[height=2160][fps>=48]\"", // 1 2160p60
" -f \"bestvideo[height=2160][fps<=32]\"", // 2 2160p30
" -f \"bestvideo[height=1440][fps>=48]\"", // 3 1440p60
" -f \"bestvideo[height=1440][fps<=32]\"", // 4 1440p30
" -f \"bestvideo[height=1080][fps>=48]\"", // 5 1080p60
" -f \"bestvideo[height=1080][fps<=32]\"", // 6 1080p30
" -f \"bestvideo[height=720][fps>=48]\"", // 7 720p60
" -f \"bestvideo[height=720][fps<=32]\"", // 8 720p30
" -f \"bestvideo[height=480]\"", // 9 480p
" -f \"bestvideo[height=360]\"", // 10 360p
" -f \"bestvideo[height=240]\"", // 11 240p
" -f \"bestvideo[height=144]\"", // 12 144p
" -f \"bestvideo[height=4320][fps>=48]\"", // 13 4320p60
" -f \"bestvideo[height=4320][fps<=32]\"" // 14 4320p30
};
/// <summary>
/// Built-in best quality for audio downloads
/// Built-in audio qualities
/// </summary>
public static string bestAudio = " -f bestaudio --extract-audio --audio-format best --audio-quality 0";
public static string goodAudio = " -x --audio-format mp3 --audio-quality 256K";
public static string[] audioQualities = {
" -f bestaudio --extract-audio --audio-format best --audio-quality 0", // 0
" -x --audio-format mp3 --audio-quality 320K", // 1
" -x --audio-format mp3 --audio-quality 256K", // 2
" -x --audio-format mp3 --audio-quality 224K", // 3
" -x --audio-format mp3 --audio-quality 192K", // 4
" -x --audio-format mp3 --audio-quality 160K", // 5
" -x --audio-format mp3 --audio-quality 128K", // 6
" -x --audio-format mp3 --audio-quality 96K", // 7
" -x --audio-format mp3 --audio-quality 64K" // 8
};
/// <summary>
/// The default file-name schema used
/// </summary>
public static string defaultSchema = "%(title)s-%(id)s.%(ext)s";

/// <summary>
/// Downloads files using the best preset available.
/// Begins the download sequence
/// </summary>
/// <param name="URL">URL of the file</param>
/// <param name="downloadType">Download type; (0) Video, (1) Audio, (2) Custom</param>
/// <param name="args">Custom arguments passed to the application</param>
/// <returns>A boolean based on the success of the download</returns>
public static bool downloadBest(string URL, int downloadType, string args = "") {
/// <param name="URL">The URL of the video/audio/whatever to download</param>
/// <param name="downloadType">Int for the type, 0 = video, 1 = audio, 2 = custom</param>
/// <param name="downloadQuality">Int for the quality</param>
/// <param name="args">Arugments for custom downloads</param>
/// <returns></returns>
public static bool startDownload(string URL, int downloadType, int downloadQuality, string args) {
if (string.IsNullOrWhiteSpace(URL)) {
MessageBox.Show("Please enter a URL before trying to download.");
return false;
}

if (URL.StartsWith("http://"))
URL = "https" + URL.Substring(4);

Expand Down Expand Up @@ -110,21 +135,21 @@ public static bool downloadBest(string URL, int downloadType, string args = "")
else
outputFolder = " -o \"" + Downloads.Default.downloadPath + "\\" + Downloads.Default.fileNameSchema + "\"";

if (usehlsFF)
if (usehlsFF && isReddit(URL))
setArgs = URL + hlsFF + outputFolder;
else
setArgs = URL + bestVideo + hlsFF + outputFolder;
setArgs = URL + videoQualities[downloadQuality] + hlsFF + outputFolder;
break;
case 1: // audio
if (Downloads.Default.separateDownloads)
outputFolder = " -o \"" + Downloads.Default.downloadPath + "\\Audio\\" + Downloads.Default.fileNameSchema + "\"";
else
outputFolder = " -o \"" + Downloads.Default.downloadPath + "\\" + Downloads.Default.fileNameSchema + "\"";

if (usehlsFF)
if (usehlsFF && isReddit(URL))
setArgs = URL + hlsFF + outputFolder;
else
setArgs = URL + bestAudio + hlsFF + outputFolder;
setArgs = URL + audioQualities[downloadQuality] + hlsFF + outputFolder;
break;
case 2: // custom
if (Downloads.Default.separateDownloads)
Expand All @@ -134,6 +159,9 @@ public static bool downloadBest(string URL, int downloadType, string args = "")

setArgs = URL + args + outputFolder;
break;
default:
MessageBox.Show("Wow, this is weird. Your download was classified as 'default'. Let me know how this happened, please");
return false;
}

Downloader.StartInfo.Arguments = setArgs;
Expand All @@ -151,11 +179,6 @@ public static bool downloadBest(string URL, int downloadType, string args = "")
}
}

public static bool downloadCustom() {
MessageBox.Show("wip");
return false;
}

/// <summary>
/// Downloads the latest version of youtube-dl
/// </summary>
Expand Down Expand Up @@ -259,5 +282,19 @@ public static bool updateYoutubeDL() {
return false;
}
}

public static bool isReddit(string url) {
if (url.StartsWith("http://"))
url = url.Replace("http://", "https://");
if (url.StartsWith("https://www."))
url = url.Replace("https://www.", "https://");

if (url.StartsWith("https://redd.it") || url.StartsWith("https://www.reddit.com")) {
return true;
}
else {
return false;
}
}
}
}
53 changes: 47 additions & 6 deletions Forms/frmMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 42f3b9c

Please sign in to comment.