Skip to content

Commit

Permalink
Merge pull request #35 from dantheman213/release/v0.7.0
Browse files Browse the repository at this point in the history
Release/v0.7.0
  • Loading branch information
dantheman213 authored Jan 29, 2020
2 parents 743d9a6 + ef2ae83 commit 716049a
Show file tree
Hide file tree
Showing 28 changed files with 2,522 additions and 629 deletions.
31 changes: 31 additions & 0 deletions JackTheVideoRipper/JackTheVideoRipper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,13 @@
<ItemGroup>
<Compile Include="src\AtomicParsley.cs" />
<Compile Include="src\FFmpeg.cs" />
<Compile Include="src\Import.cs" />
<Compile Include="src\models\DownloadMediaItem.cs" />
<Compile Include="src\models\MediaInfoData.cs" />
<Compile Include="src\models\PlaylistInfoItem.cs" />
<Compile Include="src\models\ProcessUpdateRow.cs" />
<Compile Include="src\AppUpdate.cs" />
<Compile Include="src\models\Settings.cs" />
<Compile Include="views\FrameAbout.cs">
<SubType>Form</SubType>
</Compile>
Expand All @@ -89,6 +93,24 @@
<Compile Include="views\FrameConvert.Designer.cs">
<DependentUpon>FrameConvert.cs</DependentUpon>
</Compile>
<Compile Include="views\FrameImportPlaylist.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="views\FrameImportPlaylist.Designer.cs">
<DependentUpon>FrameImportPlaylist.cs</DependentUpon>
</Compile>
<Compile Include="views\FrameNewMediaBatch.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="views\FrameNewMediaBatch.Designer.cs">
<DependentUpon>FrameNewMediaBatch.cs</DependentUpon>
</Compile>
<Compile Include="views\FrameSettings.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="views\FrameSettings.Designer.cs">
<DependentUpon>FrameSettings.cs</DependentUpon>
</Compile>
<Compile Include="views\FrameYTDLDependencyInstall.cs">
<SubType>Form</SubType>
</Compile>
Expand Down Expand Up @@ -125,6 +147,15 @@
<EmbeddedResource Include="views\FrameConvert.resx">
<DependentUpon>FrameConvert.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="views\FrameImportPlaylist.resx">
<DependentUpon>FrameImportPlaylist.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="views\FrameNewMediaBatch.resx">
<DependentUpon>FrameNewMediaBatch.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="views\FrameSettings.resx">
<DependentUpon>FrameSettings.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="views\FrameYTDLDependencyInstall.resx">
<DependentUpon>FrameYTDLDependencyInstall.cs</DependentUpon>
</EmbeddedResource>
Expand Down
4 changes: 2 additions & 2 deletions JackTheVideoRipper/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.6.1.0")]
[assembly: AssemblyFileVersion("0.6.1.0")]
[assembly: AssemblyVersion("0.7.0.0")]
[assembly: AssemblyFileVersion("0.7.0.0")]
2 changes: 1 addition & 1 deletion JackTheVideoRipper/src/CLI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static Process runYouTubeCommand(string bin, string opts)
startInfo.RedirectStandardOutput = true;
startInfo.CreateNoWindow = true;
process.StartInfo = startInfo;
process.Start();
//process.Start(); // TODO: remove?
}
catch (Exception ex)
{
Expand Down
8 changes: 8 additions & 0 deletions JackTheVideoRipper/src/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,13 @@ public static string stripIllegalFileNameChars(string str)

// return string.Join("_", str.Split(Path.GetInvalidFileNameChars()));
}

private static Random random = new Random();
public static string RandomString(int length)
{
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
return new string(Enumerable.Repeat(chars, length)
.Select(s => s[random.Next(s.Length)]).ToArray());
}
}
}
23 changes: 23 additions & 0 deletions JackTheVideoRipper/src/Import.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace JackTheVideoRipper
{
class Import
{
public static List<string> getAllUrlsFromPayload(string s)
{
var result = new List<string>();
foreach (Match item in Regex.Matches(s, @"(http|ftp|https):\/\/([\w\-_]+(?:(?:\.[\w\-_]+)+))([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])?"))
{
result.Add(item.Value);
}

return result;
}
}
}
45 changes: 45 additions & 0 deletions JackTheVideoRipper/src/YouTubeDL.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net;
Expand Down Expand Up @@ -85,12 +86,56 @@ public static string downloadThumbnail(string thumbnailUrl)
return null;
}

public static List<PlaylistInfoItem> getPlaylistMetadata(string url)
{
string opts = "-i --no-warnings --no-cache-dir --dump-json --flat-playlist --skip-download --yes-playlist " + url;
var p = CLI.runYouTubeCommand(binPath, opts);
p.Start();

string json = p.StandardOutput.ReadToEnd().Trim();
// youtube-dl returns an individual json object per line
json = "[" + json;
int i = json.IndexOf('\n');
while (i > -1)
{
json = json.Insert(i, ",");
i = json.IndexOf('\n', i + 2);
}
json += "]";
return JsonConvert.DeserializeObject<List<PlaylistInfoItem>>(json);
}

public static MediaInfoData getMediaData(string url)
{
string opts = "-s --no-warnings --no-cache-dir --print-json " + url;
var p = CLI.runYouTubeCommand(binPath, opts);
p.Start();
string json = p.StandardOutput.ReadToEnd().Trim();
return JsonConvert.DeserializeObject<MediaInfoData>(json);
}

public static string getExtractors()
{
string opts = "--list-extractors";
var p = CLI.runYouTubeCommand(binPath, opts);
p.Start();
return p.StandardOutput.ReadToEnd().Trim();
}

public static string getVersion()
{
string opts = "--version";
var p = CLI.runYouTubeCommand(binPath, opts);
p.Start();
return p.StandardOutput.ReadToEnd().Trim();
}

public static string getTitle(string url)
{
string opts = "--get-title " + url;
var p = CLI.runYouTubeCommand(binPath, opts);
p.Start();
return p.StandardOutput.ReadToEnd().Trim();
}
}
}
16 changes: 16 additions & 0 deletions JackTheVideoRipper/src/models/DownloadMediaItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JackTheVideoRipper
{
public class DownloadMediaItem
{
public string title { get; set; }
public string url { get; set; }
public string opts { get; set; }
public string filePath { get; set; }
}
}
14 changes: 14 additions & 0 deletions JackTheVideoRipper/src/models/PlaylistInfoItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JackTheVideoRipper
{
class PlaylistInfoItem
{
public string id { get; set; }
public string title { get; set; }
}
}
4 changes: 3 additions & 1 deletion JackTheVideoRipper/src/models/ProcessUpdateRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class ProcessUpdateRow
public Process proc { get; set; }
public ListViewItem item { get; set; }
public List<string> results { get; set; }
public int cursor { get; set; }
public int cursor { get; set; } // where in message buffer are we
public bool started = false;
public bool finished = false;
}
}
32 changes: 32 additions & 0 deletions JackTheVideoRipper/src/models/Settings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Environment;

namespace JackTheVideoRipper
{
public class Settings
{
public static string dir = String.Format("{0}\\JackTheVideoRipper\\settings", Environment.GetFolderPath(SpecialFolder.CommonApplicationData));
public static string filePath = String.Format("{0}\\settings.json", dir);
public string defaultDownloadPath { get; set; }
public int maxConcurrentDownloads { get; set; }

public static bool Exists()
{
return File.Exists(filePath);
}

public static Settings generateDefaultSettings()
{
var s = new Settings();
s.defaultDownloadPath = YouTubeDL.defaultDownloadPath;
s.maxConcurrentDownloads = 5;
return s;
}
}
}
19 changes: 17 additions & 2 deletions JackTheVideoRipper/views/FrameAbout.Designer.cs

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

5 changes: 3 additions & 2 deletions JackTheVideoRipper/views/FrameAbout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ private void FrameAbout_Load(object sender, EventArgs e)

try
{
var p = CLI.runYouTubeCommand(YouTubeDL.binPath, "--list-extractors");
var lines ="* " + p.StandardOutput.ReadToEnd().Trim().Replace("\n", "\r\n* ");
var lines = "* " + YouTubeDL.getExtractors().Replace("\n", "\r\n* ");
textExtractors.Text = lines;

labelYouTubeDL.Text = String.Format("youtube-dl {0}", YouTubeDL.getVersion());
}
catch (Exception ex)
{
Expand Down
Loading

0 comments on commit 716049a

Please sign in to comment.