Use new PictureIDLarge and PictureSize.Native
This commit is contained in:
parent
df4739cbf4
commit
b0d1f692a3
@ -165,9 +165,8 @@ namespace DtoImporterService
|
|||||||
if (item.PictureId is not null)
|
if (item.PictureId is not null)
|
||||||
book.PictureId = item.PictureId;
|
book.PictureId = item.PictureId;
|
||||||
|
|
||||||
// set/update book-specific info which may have changed
|
if (item.PictureLarge is not null)
|
||||||
if (item.PictureId_1215 is not null)
|
book.PictureLarge = item.PictureLarge;
|
||||||
book.PictureId_1215 = item.PictureId_1215;
|
|
||||||
|
|
||||||
book.UpdateProductRating(item.Product_OverallStars, item.Product_PerformanceStars, item.Product_StoryStars);
|
book.UpdateProductRating(item.Product_OverallStars, item.Product_PerformanceStars, item.Product_StoryStars);
|
||||||
|
|
||||||
|
|||||||
@ -63,9 +63,9 @@ namespace FileLiberator
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
(string picId, PictureSize size) = libraryBook.Book.PictureId_1215 is null ?
|
(string picId, PictureSize size) = libraryBook.Book.PictureLarge is null ?
|
||||||
(libraryBook.Book.PictureId, PictureSize._500x500) :
|
(libraryBook.Book.PictureId, PictureSize.Native) :
|
||||||
(libraryBook.Book.PictureId_1215, PictureSize._1215x1215);
|
(libraryBook.Book.PictureLarge, PictureSize.Native);
|
||||||
|
|
||||||
var picBytes = PictureStorage.GetPictureSynchronously(new PictureDefinition(picId, size));
|
var picBytes = PictureStorage.GetPictureSynchronously(new PictureDefinition(picId, size));
|
||||||
|
|
||||||
|
|||||||
@ -8,13 +8,13 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace LibationFileManager
|
namespace LibationFileManager
|
||||||
{
|
{
|
||||||
public enum PictureSize { _80x80 = 80, _300x300 = 300, _500x500 = 500 , _1215x1215 = 1215 }
|
public enum PictureSize { Native, _80x80 = 80, _300x300 = 300, _500x500 = 500 }
|
||||||
public class PictureCachedEventArgs : EventArgs
|
public class PictureCachedEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
public PictureDefinition Definition { get; internal set; }
|
public PictureDefinition Definition { get; internal set; }
|
||||||
public byte[] Picture { get; internal set; }
|
public byte[] Picture { get; internal set; }
|
||||||
}
|
}
|
||||||
public struct PictureDefinition
|
public struct PictureDefinition : IEquatable<PictureDefinition>
|
||||||
{
|
{
|
||||||
public string PictureId { get; }
|
public string PictureId { get; }
|
||||||
public PictureSize Size { get; }
|
public PictureSize Size { get; }
|
||||||
@ -24,6 +24,11 @@ namespace LibationFileManager
|
|||||||
PictureId = pictureId;
|
PictureId = pictureId;
|
||||||
Size = pictureSize;
|
Size = pictureSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Equals(PictureDefinition other)
|
||||||
|
{
|
||||||
|
return PictureId == other.PictureId && Size == other.Size;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public static class PictureStorage
|
public static class PictureStorage
|
||||||
{
|
{
|
||||||
@ -113,8 +118,8 @@ namespace LibationFileManager
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sz = (int)def.Size;
|
var sizeStr = def.Size == PictureSize.Native ? "" : $"._SL{(int)def.Size}_";
|
||||||
var bytes = imageDownloadClient.GetByteArrayAsync("ht" + $"tps://images-na.ssl-images-amazon.com/images/I/{def.PictureId}._SL{sz}_.jpg").Result;
|
var bytes = imageDownloadClient.GetByteArrayAsync("ht" + $"tps://images-na.ssl-images-amazon.com/images/I/{def.PictureId}{sizeStr}.jpg").Result;
|
||||||
|
|
||||||
// save image file. make sure to not save default image
|
// save image file. make sure to not save default image
|
||||||
var path = getPath(def);
|
var path = getPath(def);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user