diff options
| author | Andrew Rabert <ar@nullsum.net> | 2018-12-27 18:27:57 -0500 |
|---|---|---|
| committer | Andrew Rabert <ar@nullsum.net> | 2018-12-27 18:27:57 -0500 |
| commit | a86b71899ec52c44ddc6c3018e8cc5e9d7ff4d62 (patch) | |
| tree | a74f6ea4a8abfa1664a605d31d48bc38245ccf58 /MediaBrowser.Controller/Entities/BaseItemExtensions.cs | |
| parent | 9bac3ac616b01f67db98381feb09d34ebe821f9a (diff) | |
Add GPL modules
Diffstat (limited to 'MediaBrowser.Controller/Entities/BaseItemExtensions.cs')
| -rw-r--r-- | MediaBrowser.Controller/Entities/BaseItemExtensions.cs | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/MediaBrowser.Controller/Entities/BaseItemExtensions.cs b/MediaBrowser.Controller/Entities/BaseItemExtensions.cs new file mode 100644 index 000000000..c56a370a8 --- /dev/null +++ b/MediaBrowser.Controller/Entities/BaseItemExtensions.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using MediaBrowser.Controller.Library; +using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Entities; +using MediaBrowser.Model.IO; +using MediaBrowser.Model.Dto; +using MediaBrowser.Model.Querying; + +namespace MediaBrowser.Controller.Entities +{ + public static class BaseItemExtensions + { + /// <summary> + /// Gets the image path. + /// </summary> + /// <param name="item">The item.</param> + /// <param name="imageType">Type of the image.</param> + /// <returns>System.String.</returns> + public static string GetImagePath(this BaseItem item, ImageType imageType) + { + return item.GetImagePath(imageType, 0); + } + + public static bool HasImage(this BaseItem item, ImageType imageType) + { + return item.HasImage(imageType, 0); + } + + /// <summary> + /// Sets the image path. + /// </summary> + /// <param name="item">The item.</param> + /// <param name="imageType">Type of the image.</param> + /// <param name="file">The file.</param> + public static void SetImagePath(this BaseItem item, ImageType imageType, FileSystemMetadata file) + { + item.SetImagePath(imageType, 0, file); + } + + /// <summary> + /// Sets the image path. + /// </summary> + /// <param name="item">The item.</param> + /// <param name="imageType">Type of the image.</param> + /// <param name="file">The file.</param> + public static void SetImagePath(this BaseItem item, ImageType imageType, string file) + { + if (file.StartsWith("http", System.StringComparison.OrdinalIgnoreCase)) + { + item.SetImage(new ItemImageInfo + { + Path = file, + Type = imageType + }, 0); + } + else + { + item.SetImagePath(imageType, BaseItem.FileSystem.GetFileInfo(file)); + } + } + } +} |
