Skip to content

Commit

Permalink
Support new video URL format.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdpurcell committed Aug 5, 2018
1 parent 97f26e2 commit 899f67a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions RechatTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
using System;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;

namespace RechatTool {
internal class Program {
public const string Version = "1.5.0.3";
public const string Version = "1.5.0.4";

private static int Main(string[] args) {
int iArg = 0;
Expand Down Expand Up @@ -134,8 +135,9 @@ void UpdateProgress(int segmentCount, TimeSpan? contentOffset) {
}
if (!Uri.TryCreate(s, UriKind.Absolute, out Uri uri)) return null;
if (!hosts.Any(h => uri.Host.Equals(h, StringComparison.OrdinalIgnoreCase))) return null;
if (!uri.AbsolutePath.StartsWith("/videos/", StringComparison.Ordinal)) return null;
return uri.AbsolutePath.Substring(8).TryParseInt64();
Match match = Regex.Match(uri.AbsolutePath, "^/(videos|[^/]+/video)/(?<videoId>[0-9]+)$");
if (!match.Success) return null;
return match.Groups["videoId"].Value.TryParseInt64();
}

private class InvalidArgumentException : Exception { }
Expand Down

0 comments on commit 899f67a

Please sign in to comment.