updated wrapper

net6.0
Don Oerkfitz 4 years ago
parent c5b3ebce80
commit 52f0f8f52c

@ -83,5 +83,30 @@ namespace Common.Library.DataLayer.DAO.Websites.JasonNeumannAudio.com
DisposeConnection();
}
}
// public void InsertWorkPageItem(WorkPageDTO item)
// {
// InitConnection();
// WorkPageDTOCollection items = new();
// try
// {
// DBCommand.CommandType = CommandType.StoredProcedure;
// DBCommand.CommandText = "work_page_insert_work_page_item";
// // DBCommand.Parameters.AddWithValue("@TypeID", (int)workPageType);
// DBCommand.ExecuteNonQuery();
// }
// catch (Exception)
// {
// throw;
// }
// finally
// {
// DisposeConnection();
// }
// }
}
}

@ -1,15 +1,61 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using TMDbLib;
using TMDbLib.Client;
using TMDbLib.Objects.Find;
namespace Common.Library.TMDB
{
public class TMDBWrapper
{
private readonly string ApiKey;
private TMDbClient tMDbClient;
public TMDBWrapper(string apiKey)
{
ApiKey = apiKey;
tMDbClient = new(ApiKey);
}
public string GetPosterLink(string imdbID)
{
string posterLink = null;
FindContainer container = tMDbClient.FindAsync(FindExternalSource.Imdb, imdbID).Result;
if (container.MovieResults.Count > 0)
{
posterLink = container.MovieResults[0].PosterPath;
}
else if(container.TvResults.Count > 0)
{
posterLink = container.TvResults[0].PosterPath;
}
return $"https://www.themoviedb.org/t/p/original{posterLink}";
}
public List<string> GetPosterLinks(List<string> imdbIDs)
{
//> TODO: Refactor to make it better.
List<string> returnLinks = new();
imdbIDs.ForEach(imdbID =>
{
FindContainer find = tMDbClient.FindAsync(FindExternalSource.Imdb, imdbID).Result;
if(find.MovieResults.Count > 0)
{
returnLinks.Add($"https://www.themoviedb.org/t/p/original{find.MovieResults[0].PosterPath}");
}
else if(find.TvResults.Count > 0)
{
returnLinks.Add($"https://www.themoviedb.org/t/p/original{find.TvResults[0].PosterPath}");
}
});
return returnLinks;
}
}
}
Loading…
Cancel
Save