Fix id parser

This commit is contained in:
Maksym Pavlenko
2017-01-17 14:33:31 -08:00
parent 8084a81d3a
commit dde0646e0e
2 changed files with 3 additions and 1 deletions
+2 -1
View File
@@ -32,9 +32,10 @@ namespace Podsync.Services.Links
https://www.youtube.com/playlist?list=PLCB9F975ECF01953C
https://www.youtube.com/channel/UC5XPnUk8Vvv_pWslhwom6Og
https://www.youtube.com/user/fxigr1
https://www.youtube.com/channel/UCrlakW-ewUT8sOod6Wmzyow/videos
*/
private static readonly Regex YouTubeRegex = new Regex(@"^(?:https?://)?(?:www\.)?(?:youtube.com/)(?<type>user|channel|playlist|watch)/?(?<id>\w+)?", RegexOptions.Compiled);
private static readonly Regex YouTubeRegex = new Regex(@"^(?:https?://)?(?:www\.)?(?:youtube.com/)(?<type>user|channel|playlist|watch)/?(?<id>[-\w]+)?", RegexOptions.Compiled);
/*
Vimeo groups, channels and users
@@ -17,6 +17,7 @@ namespace Podsync.Tests.Services.Links
[InlineData("https://www.youtube.com/user/UC5XPnUk8Vvv_pWslhwom6Og/playlists", LinkType.User, "UC5XPnUk8Vvv_pWslhwom6Og")]
[InlineData("https://www.youtube.com/playlist?list=PLP8qlV2aurYqdhyXW9ErqUW9Fw9F_mheM", LinkType.Playlist, "PLP8qlV2aurYqdhyXW9ErqUW9Fw9F_mheM")]
[InlineData("https://www.youtube.com/user/NEMAGIA/videos", LinkType.User, "NEMAGIA")]
[InlineData("https://www.youtube.com/channel/UCrlakW-ewUT8sOod6Wmzyow/videos", LinkType.Channel, "UCrlakW-ewUT8sOod6Wmzyow")]
public void ParseYoutubeLinks(string link, LinkType linkType, string id)
{
var info = _linkService.Parse(new Uri(link));