Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/ipv6'
Browse files Browse the repository at this point in the history
  • Loading branch information
sk-zk committed Jul 3, 2019
2 parents 2c95dc1 + e4d9677 commit 3a0bf5c
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 59 deletions.
28 changes: 17 additions & 11 deletions linux/README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
Creates a Youtube ASH file from the command line.

### Requirements
The following libraries must be present:
The following libraries / programs must be present:

libASMedia.so *(from Audiosurf 2/Audiosurf2_Data/Plugins/x86_64/)*
libbass.so *(from Audiosurf 2/Audiosurf2_Data/Plugins/x86_64/)*
TagLib#
youtube-dl *(make sure to install the most recent version)*
* libASMedia.so *(from Audiosurf 2/Audiosurf2_Data/Plugins/x86_64/)*
* libbass.so *(from Audiosurf 2/Audiosurf2_Data/Plugins/x86_64/)*
* TagLib#
* youtube-dl *(make sure to install the most recent version)*

### Usage

`mono yashgen.exe video_id [destination]`
`yashgen video_id destination [-6]`

video_id: The ID of the YouTube video.

destination: The destination folder (optional).
`video_id`: The ID of the YouTube video.
`destination`: The destination folder.
`-6`: Force IPv6 (optional).

### Troubleshooting

#### `This video is not available`
If youtube-dl exits with this message but the video is available, try
the `-6` flag.

#### DllNotFoundException
In case of a DllNotFoundException, run the program with `MONO_LOG_LEVEL=debug` and `MONO_LOG_MASK=dll`. The output should tell you which libraries are missing.
In case of a DllNotFoundException, run the program with `MONO_LOG_LEVEL=debug`
and `MONO_LOG_MASK=dll`. The output should tell you which libraries are missing.

You might also have to move `libASMedia` and `libbass` to `/usr/lib/`.

#### ALSA: `cannot find card 0`
You may need to install a [dummy soundcard](https://www.raspberrypi.org/forums/viewtopic.php?p=485842&sid=5b596e5473571e5918872059e32a6873#p485842) on your system.
You may need to install a [dummy soundcard](https://www.raspberrypi.org/forums/viewtopic.php?p=485842&sid=5b596e5473571e5918872059e32a6873#p485842)
on your system.
2 changes: 1 addition & 1 deletion linux/yashgen.sln
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ Global
SolutionGuid = {FEDB9C9C-DB17-4BAA-B928-9E0FB18E7E0E}
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
version = 1.1
version = 1.1.1
EndGlobalSection
EndGlobal
16 changes: 10 additions & 6 deletions linux/yashgen/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,22 @@ static void Main(string[] args)
if (args.Length == 0)
{
Console.WriteLine("Usage:");
Console.WriteLine("yashgen video_id [destination]");
Console.WriteLine("yashgen video_id destination [-6]");
Environment.Exit(ExitNoArgs);
}

var id = args[0];
var path = args.Length > 1 ? args[1] : "";

// force ytdl to use ipv6
// fixes "This video is not available" for auto-generated videos
var ipv6 = args.Contains("-6");

try
{
if (IsYoutubeId(id))
{
ProcessVideo(id, path);
ProcessVideo(id, path, ipv6);
Console.WriteLine("Done\n");
}
else
Expand Down Expand Up @@ -69,19 +73,19 @@ static bool IsYoutubeId(string input)
return true;
}

static void ProcessVideo(string videoId, string path)
static void ProcessVideo(string videoId, string path, bool ipv6 = false)
{
CreateAndSaveYash(videoId, path);
CreateAndSaveYash(videoId, path, ipv6);
}

static void CreateAndSaveYash(string videoId, string path)
static void CreateAndSaveYash(string videoId, string path, bool ipv6 = false)
{
Console.WriteLine("Processing {0} now", videoId);
Console.WriteLine("Downloading audio");
string ytAudioFile;
try
{
ytAudioFile = YoutubeDl.CallYoutubeDl(videoId);
ytAudioFile = YoutubeDl.CallYoutubeDl(videoId, ipv6);
}
catch (YoutubeDlException)
{
Expand Down
16 changes: 9 additions & 7 deletions linux/yashgen/YoutubeDl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,21 @@ class YoutubeDl
/// </summary>
/// <param name="videoId">The ID of the video.</param>
/// <returns>The path to the downloaded file.</returns>
public static string CallYoutubeDl(string videoId)
public static string CallYoutubeDl(string videoId, bool ipv6 = false)
{
errors = "";
string tempFile = Path.Combine(OUTPUT_FOLDER, videoId + ".wav");

// workaround for "invalid retry count" bug with leading dashes in IDs
var videoUrl = $"https://www.youtube.com/watch?v={videoId}";

var videoUrl = $"https://www.youtube.com/watch?v={videoId}";

var args = $"--ignore-config -f bestaudio -x --audio-format wav --add-metadata " +
$"-o {OUTPUT_FOLDER}/%(id)s.%(ext)s \"{videoUrl}\"";

if (ipv6) args += " -6"; // force ipv6

ProcessStartInfo info = new ProcessStartInfo(
"youtube-dl",
$"--ignore-config -f bestaudio -x --audio-format wav --add-metadata " +
$"-o {OUTPUT_FOLDER}/%(id)s.%(ext)s \"{videoUrl}\""
);
"youtube-dl", args);
info.CreateNoWindow = true;
info.UseShellExecute = false;
info.RedirectStandardOutput = true;
Expand Down
2 changes: 1 addition & 1 deletion linux/yashgen/yashgen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<ReleaseVersion>1.1</ReleaseVersion>
<ReleaseVersion>1.1.1</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
20 changes: 10 additions & 10 deletions windows/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
Creates a Youtube ASH file from the command line.

### Requirements
The following libraries must be present:
The following libraries / programs must be present:

BASS *(from the AS2 directory)*
ffmpeg
TagLib#
UnityMediaPlayer.dll *(from the AS2 directory)*
youtube-dl
* BASS *(from the AS2 directory)*
* ffmpeg
* TagLib#
* UnityMediaPlayer.dll *(from the AS2 directory)*
* youtube-dl

### Usage

`yashgen video_id [destination]`
`yashgen video_id destination [-6]`

video_id: The ID of the YouTube video.

destination: The destination folder (optional).
`video_id`: The ID of the YouTube video.
`destination`: The destination folder.
`-6`: Force IPv6 (optional).
16 changes: 10 additions & 6 deletions windows/yashgen/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,22 @@ static void Main(string[] args)
if(args.Length == 0)
{
Console.WriteLine("Usage:");
Console.WriteLine("yashgen video_id [destination]");
Console.WriteLine("yashgen video_id destination [-6]");
Environment.Exit(ExitNoArgs);
}

var id = args[0];
var path = args.Length > 1 ? args[1] : "";

// force ytdl to use ipv6
// fixes "This video is not available" for auto-generated videos
var ipv6 = args.Contains("-6");

try
{
if (IsYoutubeId(id))
{
ProcessVideo(id, path);
ProcessVideo(id, path, ipv6);
Console.WriteLine("Done\n");
}
else
Expand Down Expand Up @@ -69,19 +73,19 @@ static bool IsYoutubeId(string input)
return true;
}

static void ProcessVideo(string videoId, string path)
static void ProcessVideo(string videoId, string path, bool ipv6 = false)
{
CreateAndSaveYash(videoId, path);
CreateAndSaveYash(videoId, path, ipv6);
}

static void CreateAndSaveYash(string videoId, string path)
static void CreateAndSaveYash(string videoId, string path, bool ipv6 = false)
{
Console.WriteLine("Processing {0} now", videoId);
Console.WriteLine("Downloading audio");
string ytAudioFile;
try
{
ytAudioFile = YoutubeDl.CallYoutubeDl(videoId);
ytAudioFile = YoutubeDl.CallYoutubeDl(videoId, ipv6);
}
catch (YoutubeDlException)
{
Expand Down
4 changes: 2 additions & 2 deletions windows/yashgen/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyVersion("1.1.1.0")]
[assembly: AssemblyFileVersion("1.1.1.0")]
31 changes: 16 additions & 15 deletions windows/yashgen/YoutubeDl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,28 @@ class YoutubeDl
/// </summary>
/// <param name="videoId">The ID of the video.</param>
/// <returns>The path to the downloaded file.</returns>
public static string CallYoutubeDl(string videoId)
public static string CallYoutubeDl(string videoId, bool ipv6 = false)
{
errors = "";
string tempFile = Path.Combine(OUTPUT_FOLDER, videoId + ".m4a");

// workaround for "invalid retry count" bug with leading dashes in IDs
var videoUrl = $"https://www.youtube.com/watch?v={videoId}";
var videoUrl = $"https://www.youtube.com/watch?v={videoId}";

var args = $"--ignore-config -f bestaudio -x --audio-format m4a --add-metadata " +
$"-o {OUTPUT_FOLDER}/%(id)s.%(ext)s \"{videoUrl}\"";

if (ipv6) args += " -6"; // force ipv6

ProcessStartInfo info = new ProcessStartInfo(
"youtube-dl.exe",
$"--ignore-config -f bestaudio -x --audio-format m4a --add-metadata " +
$"-o {OUTPUT_FOLDER}/%(id)s.%(ext)s \"{videoUrl}\""
);
"youtube-dl.exe", args);
info.CreateNoWindow = true;
info.UseShellExecute = false;
info.RedirectStandardOutput = true;
info.RedirectStandardError = true;
Process process = new Process();
process.StartInfo = info;
//process.OutputDataReceived += Process_OutputDataReceived;
process.OutputDataReceived += Process_OutputDataReceived;
process.ErrorDataReceived += Process_ErrorDataReceived;
process.Start();
process.BeginOutputReadLine();
Expand All @@ -57,19 +59,18 @@ public static string CallYoutubeDl(string videoId)
return tempFile;
}

/*private static void Process_OutputDataReceived(object sender, DataReceivedEventArgs e)
private static void Process_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
}*/
#if DEBUG
Console.WriteLine(e.Data);
#endif
}

private static void Process_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
if (e.Data != null)
if (e.Data != null && e.Data.Trim() != "")
{
if (e.Data.Trim() != "")
{
errors += e.Data;
}
errors += e.Data;
}
}

Expand Down

0 comments on commit 3a0bf5c

Please sign in to comment.