Fix playlist in production

This commit is contained in:
Fergal Moran
2018-05-07 21:27:32 +01:00
parent ba2b10ee78
commit 14a0208372
5 changed files with 9 additions and 6 deletions

1
docker/log.sh Executable file
View File

@@ -0,0 +1 @@
eval $(docker-machine env podnoms-vm) && docker-compose logs -f

View File

@@ -20,6 +20,7 @@ using PodNoms.Api.Services.Auth;
using PodNoms.Api.Services.Jobs;
using PodNoms.Api.Services.Processor;
using PodNoms.Api.Services.Storage;
using PodNoms.Api.Utils.RemoteParsers;
namespace PodNoms.Api.Controllers {
@@ -115,9 +116,11 @@ namespace PodNoms.Api.Controllers {
var result = _mapper.Map<PodcastEntry, PodcastEntryViewModel>(entry);
return result;
}
} else if (status == AudioType.Playlist && _hostingEnvironment.IsDevelopment()) {
} else if (status == AudioType.Playlist && YouTubeParser.ValidateUrl(item.SourceUrl)) {
entry.ProcessingStatus = ProcessingStatus.Deferred;
return Accepted(entry);
} else {
return BadRequest("Processor failed");
}
}
return BadRequest($"Unable to find podcast with ID: {item.PodcastId}");

View File

@@ -44,15 +44,14 @@ namespace PodNoms.Api.Services.Jobs {
var info = downloader.GetInfo();
var id = ((PlaylistDownloadInfo)downloader.RawProperties).Id;
if (info == AudioType.Playlist && downloader.RawProperties is PlaylistDownloadInfo) {
if (_youTubeParser.ValidateUrl(playlist.SourceUrl)) {
if (YouTubeParser.ValidateUrl(playlist.SourceUrl)) {
var searchTerm = (playlist.SourceUrl.Contains("/user/")) ? "forUsername" : "id";
resultList = await _youTubeParser.GetPlaylistEntriesForId(id);
//make sure the items are sorted in ascending date order
//so they will be processed in the order they were created
} else if (_mixcloudParser.ValidateUrl(playlist.SourceUrl)) {
} else if (MixcloudParser.ValidateUrl(playlist.SourceUrl)) {
resultList = await _mixcloudParser.GetEntries(id);
}
}
foreach (var item in resultList?.OrderBy(r => r.UploadDate)) {
if (!playlist.ParsedPlaylistItems.Any(p => p.VideoId == item.Id)) {

View File

@@ -14,7 +14,7 @@ namespace PodNoms.Api.Utils.RemoteParsers {
public MixcloudParser(IHttpClientFactory httpClientFactory) {
this._httpClientFactory = httpClientFactory;
}
public bool ValidateUrl(string url) {
public static bool ValidateUrl(string url) {
var regex = new Regex(URL_REGEX);
var result = regex.Match(url);
return result.Success;

View File

@@ -23,7 +23,7 @@ namespace PodNoms.Api.Utils.RemoteParsers {
});
}
public bool ValidateUrl(string url) {
public static bool ValidateUrl(string url) {
var regex = new Regex(URL_REGEX);
var result = regex.Match(url);
return result.Success;