From 5f24489d2b9ee008a8166b4585f8d5d341b73c38 Mon Sep 17 00:00:00 2001 From: Maksym Pavlenko Date: Thu, 12 Jan 2017 11:48:06 -0800 Subject: [PATCH] Don't allow to create audio feeds for Vimeo --- src/Podsync/Controllers/FeedController.cs | 4 ++-- src/Podsync/Helpers/Extensions.cs | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Podsync/Controllers/FeedController.cs b/src/Podsync/Controllers/FeedController.cs index 79a3d55..3d39685 100644 --- a/src/Podsync/Controllers/FeedController.cs +++ b/src/Podsync/Controllers/FeedController.cs @@ -47,9 +47,9 @@ namespace Podsync.Controllers { var linkInfo = _linkService.Parse(new Uri(request.Url)); - if (linkInfo.LinkType == LinkType.Video) + if (linkInfo.Provider != Provider.YouTube && request.Quality.HasValue && request.Quality.Value.IsAudio()) { - throw new ArgumentException("Direct links are not supported, you should provide group, channel or user link"); + throw new ArgumentException("Only YouTube supports audio feeds"); } var feed = new FeedMetadata diff --git a/src/Podsync/Helpers/Extensions.cs b/src/Podsync/Helpers/Extensions.cs index 7e175ad..6877284 100644 --- a/src/Podsync/Helpers/Extensions.cs +++ b/src/Podsync/Helpers/Extensions.cs @@ -4,6 +4,7 @@ using System.Security.Claims; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Podsync.Services; +using Podsync.Services.Resolver; namespace Podsync.Helpers { @@ -68,9 +69,14 @@ namespace Podsync.Helpers ?? "noname :("; } - public static string GetClaim(this ClaimsPrincipal claimsPrincipal, string type) + private static string GetClaim(this ClaimsPrincipal claimsPrincipal, string type) { return claimsPrincipal.Claims.FirstOrDefault(x => x.Type == type)?.Value; } + + public static bool IsAudio(this ResolveFormat format) + { + return format == ResolveFormat.AudioHigh || format == ResolveFormat.AudioLow; + } } } \ No newline at end of file