mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 14:03:29 -07:00
QualityTypes no longer an enum
This commit is contained in:
parent
49f086cf19
commit
92acb4c049
37 changed files with 585 additions and 247 deletions
|
@ -46,7 +46,7 @@ namespace NzbDrone.Core.Repository
|
|||
}
|
||||
set
|
||||
{
|
||||
Quality = value.QualityType;
|
||||
Quality = value.Quality;
|
||||
Proper = value.Proper;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace NzbDrone.Core.Repository.Quality
|
|||
|
||||
foreach (var q in Allowed)
|
||||
{
|
||||
result += (int)q + "|";
|
||||
result += q.Id + "|";
|
||||
}
|
||||
return result.Trim('|');
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ namespace NzbDrone.Core.Repository.Quality
|
|||
Allowed = new List<QualityTypes>(qualities.Length);
|
||||
foreach (var quality in qualities.Where(q => !String.IsNullOrWhiteSpace(q)))
|
||||
{
|
||||
Allowed.Add((QualityTypes)Convert.ToInt32(quality));
|
||||
Allowed.Add(QualityTypes.FindById(Convert.ToInt32(quality)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,44 +1,124 @@
|
|||
using System;
|
||||
|
||||
namespace NzbDrone.Core.Repository.Quality
|
||||
{
|
||||
// ReSharper disable InconsistentNaming
|
||||
/// <summary>
|
||||
/// Represents Video Quality
|
||||
/// </summary>
|
||||
public enum QualityTypes
|
||||
public class QualityTypes : IComparable<QualityTypes>
|
||||
{
|
||||
/// <summary>
|
||||
/// Quality is unknown
|
||||
/// </summary>
|
||||
Unknown = 0,
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int Weight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// SD File (Source could be HD)
|
||||
/// </summary>
|
||||
SDTV = 1,
|
||||
public int CompareTo(QualityTypes other)
|
||||
{
|
||||
if (other.Weight > Weight)
|
||||
return -1;
|
||||
|
||||
/// <summary>
|
||||
/// SD File (DVD Source)
|
||||
/// </summary>
|
||||
DVD = 2,
|
||||
if (other.Weight < Weight)
|
||||
return 1;
|
||||
|
||||
/// <summary>
|
||||
/// HD File (HDTV Source)
|
||||
/// </summary>
|
||||
HDTV = 4,
|
||||
if (other.Weight == Weight)
|
||||
return 0;
|
||||
|
||||
/// <summary>
|
||||
/// HD File (Online Source)
|
||||
/// </summary>
|
||||
WEBDL = 5,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// HD File (720p Blu-ray Source)
|
||||
/// </summary>
|
||||
Bluray720p = 6,
|
||||
public static bool operator !=(QualityTypes x, QualityTypes y)
|
||||
{
|
||||
return !(x == y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// HD File (1080p Blu-ray Source)
|
||||
/// </summary>
|
||||
Bluray1080p = 7,
|
||||
public static bool operator ==(QualityTypes x, QualityTypes y)
|
||||
{
|
||||
var xObj = (Object)x;
|
||||
var yObj = (object)y;
|
||||
|
||||
if (xObj == null || yObj == null)
|
||||
{
|
||||
return xObj == yObj;
|
||||
}
|
||||
|
||||
return x.CompareTo(y) == 0;
|
||||
}
|
||||
|
||||
public static bool operator >(QualityTypes x, QualityTypes y)
|
||||
{
|
||||
return x.CompareTo(y) > 0;
|
||||
}
|
||||
|
||||
public static bool operator <(QualityTypes x, QualityTypes y)
|
||||
{
|
||||
return x.CompareTo(y) < 0;
|
||||
}
|
||||
|
||||
public static bool operator <=(QualityTypes x, QualityTypes y)
|
||||
{
|
||||
return x.CompareTo(y) <= 0;
|
||||
}
|
||||
|
||||
public static bool operator >=(QualityTypes x, QualityTypes y)
|
||||
{
|
||||
return x.CompareTo(y) >= 0;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked // Overflow is fine, just wrap
|
||||
{
|
||||
int hash = 17;
|
||||
hash = hash * 23 + Weight.GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Equals(QualityTypes other)
|
||||
{
|
||||
if (ReferenceEquals(null, other)) return false;
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
return Equals(other.Weight, Weight);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
if (obj.GetType() != typeof (QualityTypes)) return false;
|
||||
return Equals((QualityTypes) obj);
|
||||
}
|
||||
|
||||
public static QualityTypes Unknown = new QualityTypes { Id = 0, Name = "Unknown", Weight = 0 };
|
||||
public static QualityTypes SDTV = new QualityTypes {Id = 1, Name = "SDTV", Weight = 1};
|
||||
public static QualityTypes DVD = new QualityTypes { Id = 2, Name = "DVD", Weight = 2 };
|
||||
public static QualityTypes HDTV = new QualityTypes { Id = 4, Name = "HDTV", Weight = 4 };
|
||||
public static QualityTypes WEBDL = new QualityTypes { Id = 5, Name = "WEBDL", Weight = 5 };
|
||||
public static QualityTypes Bluray720p = new QualityTypes { Id = 6, Name = "Bluray720p", Weight = 6 };
|
||||
public static QualityTypes Bluray1080p = new QualityTypes { Id = 7, Name = "Bluray1080p", Weight = 7 };
|
||||
|
||||
public static QualityTypes FindById(int id)
|
||||
{
|
||||
if (id == 0) return Unknown;
|
||||
if (id == 1) return SDTV;
|
||||
if (id == 2) return DVD;
|
||||
if (id == 4) return HDTV;
|
||||
if (id == 5) return WEBDL;
|
||||
if (id == 6) return Bluray720p;
|
||||
if (id == 7) return Bluray1080p;
|
||||
|
||||
throw new ArgumentException("ID does not match a known quality", "id");
|
||||
}
|
||||
|
||||
public static explicit operator QualityTypes(int id)
|
||||
{
|
||||
return FindById(id);
|
||||
}
|
||||
|
||||
public static explicit operator int(QualityTypes quality)
|
||||
{
|
||||
return quality.Id;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,7 +19,7 @@ namespace NzbDrone.Core.Repository.Search
|
|||
public string NzbInfoUrl { get; set; }
|
||||
public bool Success { get; set; }
|
||||
public ReportRejectionType SearchError { get; set; }
|
||||
public QualityTypes Quality { get; set; }
|
||||
public Quality.QualityTypes Quality { get; set; }
|
||||
public bool Proper { get; set; }
|
||||
public int Age { get; set; }
|
||||
public LanguageType Language { get; set; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue