mirror of
https://github.com/Sonarr/Sonarr.git
synced 2025-03-05 15:15:59 +02:00
New: Bluray 1080p and 2160p remux qualities
This commit is contained in:
parent
a3b90650be
commit
897f3fea99
@ -1,4 +1,4 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Core.Datastore.Migration;
|
using NzbDrone.Core.Datastore.Migration;
|
||||||
@ -24,7 +24,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
var profiles = db.Query<Profile70>("SELECT Items FROM Profiles LIMIT 1");
|
var profiles = db.Query<Profile71>("SELECT Items FROM Profiles LIMIT 1");
|
||||||
|
|
||||||
var items = profiles.First().Items;
|
var items = profiles.First().Items;
|
||||||
items.Should().HaveCount(2);
|
items.Should().HaveCount(2);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Core.Datastore.Migration;
|
using NzbDrone.Core.Datastore.Migration;
|
||||||
@ -24,7 +24,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
var profiles = db.Query<Profile70>("SELECT Items FROM Profiles LIMIT 1");
|
var profiles = db.Query<Profile71>("SELECT Items FROM Profiles LIMIT 1");
|
||||||
|
|
||||||
var items = profiles.First().Items;
|
var items = profiles.First().Items;
|
||||||
items.Should().HaveCount(4);
|
items.Should().HaveCount(4);
|
||||||
|
@ -0,0 +1,58 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using FluentAssertions;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Core.Datastore.Migration;
|
||||||
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Test.Datastore.Migration
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class add_remux_qualities_in_profileFixture : MigrationTest<add_remux_qualities_in_profile>
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void should_add_remux_to_old_profile()
|
||||||
|
{
|
||||||
|
var db = WithMigrationTestDb(c =>
|
||||||
|
{
|
||||||
|
c.Insert.IntoTable("Profiles").Row(new
|
||||||
|
{
|
||||||
|
Id = 0,
|
||||||
|
Name = "Bluray",
|
||||||
|
Cutoff = 7,
|
||||||
|
Items = "[ { \"quality\": 7, \"allowed\": true }, { \"quality\": 19, \"allowed\": true } ]"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
var profiles = db.Query<Profile122>("SELECT Items FROM Profiles LIMIT 1");
|
||||||
|
|
||||||
|
var items = profiles.First().Items;
|
||||||
|
items.Should().HaveCount(4);
|
||||||
|
items.Select(v => v.Quality).Should().BeEquivalentTo(7, 20, 19, 21);
|
||||||
|
items.Select(v => v.Allowed).Should().BeEquivalentTo(true, false, true, false);
|
||||||
|
items.Select(v => v.Name).Should().BeEquivalentTo(null, null, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_add_remux_to_old_profile_with_groups()
|
||||||
|
{
|
||||||
|
var db = WithMigrationTestDb(c =>
|
||||||
|
{
|
||||||
|
c.Insert.IntoTable("Profiles").Row(new
|
||||||
|
{
|
||||||
|
Id = 0,
|
||||||
|
Name = "Bluray",
|
||||||
|
Cutoff = 7,
|
||||||
|
Items = "[ { \"id\": 1001, \"name\": \"Why?!\", \"allowed\": true, \"items\": [{ \"quality\": 8, \"allowed\": true }, { \"quality\": 7, \"allowed\": true }] }, { \"quality\": 19, \"allowed\": true } ]"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
var profiles = db.Query<Profile122>("SELECT Items FROM Profiles LIMIT 1");
|
||||||
|
|
||||||
|
var items = profiles.First().Items;
|
||||||
|
items.Should().HaveCount(4);
|
||||||
|
items.Select(v => v.Quality).Should().BeEquivalentTo(null, 20, 19, 21);
|
||||||
|
items.Select(v => v.Allowed).Should().BeEquivalentTo(true, false, true, false);
|
||||||
|
items.Select(v => v.Name).Should().BeEquivalentTo("Why?!", null, null, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -131,6 +131,7 @@
|
|||||||
<Compile Include="Datastore\DatabaseRelationshipFixture.cs" />
|
<Compile Include="Datastore\DatabaseRelationshipFixture.cs" />
|
||||||
<Compile Include="Datastore\MappingExtentionFixture.cs" />
|
<Compile Include="Datastore\MappingExtentionFixture.cs" />
|
||||||
<Compile Include="Datastore\MarrDataLazyLoadingFixture.cs" />
|
<Compile Include="Datastore\MarrDataLazyLoadingFixture.cs" />
|
||||||
|
<Compile Include="Datastore\Migration\101_add_ultrahd_quality_in_profilesFixture.cs" />
|
||||||
<Compile Include="Datastore\Migration\117_add_webrip_qualites_in_profileFixture.cs" />
|
<Compile Include="Datastore\Migration\117_add_webrip_qualites_in_profileFixture.cs" />
|
||||||
<Compile Include="Datastore\Migration\108_fix_metadata_file_extensionsFixture.cs" />
|
<Compile Include="Datastore\Migration\108_fix_metadata_file_extensionsFixture.cs" />
|
||||||
<Compile Include="Datastore\Migration\109_import_extra_files_configFixture.cs" />
|
<Compile Include="Datastore\Migration\109_import_extra_files_configFixture.cs" />
|
||||||
@ -138,7 +139,7 @@
|
|||||||
<Compile Include="Datastore\Migration\106_update_btn_urlFixture.cs" />
|
<Compile Include="Datastore\Migration\106_update_btn_urlFixture.cs" />
|
||||||
<Compile Include="Datastore\Migration\103_fix_metadata_file_extensionsFixture.cs" />
|
<Compile Include="Datastore\Migration\103_fix_metadata_file_extensionsFixture.cs" />
|
||||||
<Compile Include="Datastore\Migration\099_extra_and_subtitle_filesFixture.cs" />
|
<Compile Include="Datastore\Migration\099_extra_and_subtitle_filesFixture.cs" />
|
||||||
<Compile Include="Datastore\Migration\101_add_ultrahd_quality_in_profilesFixture.cs" />
|
<Compile Include="Datastore\Migration\122_add_remux_qualities_in_profile.cs" />
|
||||||
<Compile Include="Datastore\Migration\071_unknown_quality_in_profileFixture.cs" />
|
<Compile Include="Datastore\Migration\071_unknown_quality_in_profileFixture.cs" />
|
||||||
<Compile Include="Datastore\Migration\072_history_downloadIdFixture.cs" />
|
<Compile Include="Datastore\Migration\072_history_downloadIdFixture.cs" />
|
||||||
<Compile Include="Datastore\Migration\070_delay_profileFixture.cs" />
|
<Compile Include="Datastore\Migration\070_delay_profileFixture.cs" />
|
||||||
|
@ -286,6 +286,16 @@ namespace NzbDrone.Core.Test.ParserTests
|
|||||||
ParseAndVerifyQuality(title, Quality.Bluray1080p, proper);
|
ParseAndVerifyQuality(title, Quality.Bluray1080p, proper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCase("Yuri!!! on ICE - S01E12[JP BD Remux][ENG subs]", false)]
|
||||||
|
[TestCase("Agents.of.S.H.I.E.L.D.S01E08.The.Well.BluRay.1080p.AVC.DTS-HD.MA.5.1.REMUX-FraMeSToR", false)]
|
||||||
|
[TestCase("Miami.Vice.2x11.Nato.Per.La.Truffa.Bluray.Remux.AVC.1080p.AC3.ITA", false)]
|
||||||
|
[TestCase("Miami.Vice.2x11.Nato.Per.La.Truffa.Bluray.Remux.AVC.AC3.ITA", false)]
|
||||||
|
[TestCase("Arrow.S03E01.The.Calm.1080p.DTS-HD.MA.5.1.AVC.REMUX-FraMeSToR", false)]
|
||||||
|
public void should_parse_bluray1080p_remux_quality(string title, bool proper)
|
||||||
|
{
|
||||||
|
ParseAndVerifyQuality(title, Quality.Bluray1080pRemux, proper);
|
||||||
|
}
|
||||||
|
|
||||||
[TestCase("House.of.Cards.US.s05e13.4K.UHD.Bluray", false)]
|
[TestCase("House.of.Cards.US.s05e13.4K.UHD.Bluray", false)]
|
||||||
[TestCase("House.of.Cards.US.s05e13.UHD.4K.Bluray", false)]
|
[TestCase("House.of.Cards.US.s05e13.UHD.4K.Bluray", false)]
|
||||||
[TestCase("[DameDesuYo] Backlog Bundle - Part 1 (BD 4K 8bit FLAC)", false)]
|
[TestCase("[DameDesuYo] Backlog Bundle - Part 1 (BD 4K 8bit FLAC)", false)]
|
||||||
@ -294,6 +304,14 @@ namespace NzbDrone.Core.Test.ParserTests
|
|||||||
ParseAndVerifyQuality(title, Quality.Bluray2160p, proper);
|
ParseAndVerifyQuality(title, Quality.Bluray2160p, proper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCase("Yuri!!! on ICE - S01E12[JP BD 2160p Remux][ENG subs]", false)]
|
||||||
|
[TestCase("Agents.of.S.H.I.E.L.D.S01E08.The.Well.BluRay.2160p.AVC.DTS-HD.MA.5.1.REMUX-FraMeSToR", false)]
|
||||||
|
[TestCase("Miami.Vice.2x11.Nato.Per.La.Truffa.Bluray.Remux.AVC.2160p.AC3.ITA", false)]
|
||||||
|
public void should_parse_bluray2160p_remux_quality(string title, bool proper)
|
||||||
|
{
|
||||||
|
ParseAndVerifyQuality(title, Quality.Bluray2160pRemux, proper);
|
||||||
|
}
|
||||||
|
|
||||||
[TestCase("POI S02E11 1080i HDTV DD5.1 MPEG2-TrollHD", false)]
|
[TestCase("POI S02E11 1080i HDTV DD5.1 MPEG2-TrollHD", false)]
|
||||||
[TestCase("How I Met Your Mother S01E18 Nothing Good Happens After 2 A.M. 720p HDTV DD5.1 MPEG2-TrollHD", false)]
|
[TestCase("How I Met Your Mother S01E18 Nothing Good Happens After 2 A.M. 720p HDTV DD5.1 MPEG2-TrollHD", false)]
|
||||||
[TestCase("The Voice S01E11 The Finals 1080i HDTV DD5.1 MPEG2-TrollHD", false)]
|
[TestCase("The Voice S01E11 The Finals 1080i HDTV DD5.1 MPEG2-TrollHD", false)]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FluentMigrator;
|
using FluentMigrator;
|
||||||
@ -19,35 +19,36 @@ namespace NzbDrone.Core.Datastore.Migration
|
|||||||
|
|
||||||
private void ConvertProfile(IDbConnection conn, IDbTransaction tran)
|
private void ConvertProfile(IDbConnection conn, IDbTransaction tran)
|
||||||
{
|
{
|
||||||
var updater = new ProfileUpdater70(conn, tran);
|
var updater = new ProfileUpdater71(conn, tran);
|
||||||
updater.PrependQuality(0);
|
updater.PrependQuality(0);
|
||||||
updater.Commit();
|
updater.Commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public class Profile70
|
|
||||||
|
public class Profile71
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public int Cutoff { get; set; }
|
public int Cutoff { get; set; }
|
||||||
public List<ProfileItem70> Items { get; set; }
|
public List<ProfileItem71> Items { get; set; }
|
||||||
public int Language { get; set; }
|
public int Language { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ProfileItem70
|
public class ProfileItem71
|
||||||
{
|
{
|
||||||
public int Quality { get; set; }
|
public int Quality { get; set; }
|
||||||
public bool Allowed { get; set; }
|
public bool Allowed { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ProfileUpdater70
|
public class ProfileUpdater71
|
||||||
{
|
{
|
||||||
private readonly IDbConnection _connection;
|
private readonly IDbConnection _connection;
|
||||||
private readonly IDbTransaction _transaction;
|
private readonly IDbTransaction _transaction;
|
||||||
|
|
||||||
private List<Profile70> _profiles;
|
private List<Profile71> _profiles;
|
||||||
private HashSet<Profile70> _changedProfiles = new HashSet<Profile70>();
|
private HashSet<Profile71> _changedProfiles = new HashSet<Profile71>();
|
||||||
|
|
||||||
public ProfileUpdater70(IDbConnection conn, IDbTransaction tran)
|
public ProfileUpdater71(IDbConnection conn, IDbTransaction tran)
|
||||||
{
|
{
|
||||||
_connection = conn;
|
_connection = conn;
|
||||||
_transaction = tran;
|
_transaction = tran;
|
||||||
@ -82,7 +83,7 @@ namespace NzbDrone.Core.Datastore.Migration
|
|||||||
{
|
{
|
||||||
if (profile.Items.Any(v => v.Quality == quality)) continue;
|
if (profile.Items.Any(v => v.Quality == quality)) continue;
|
||||||
|
|
||||||
profile.Items.Insert(0, new ProfileItem70
|
profile.Items.Insert(0, new ProfileItem71
|
||||||
{
|
{
|
||||||
Quality = quality,
|
Quality = quality,
|
||||||
Allowed = false
|
Allowed = false
|
||||||
@ -98,7 +99,7 @@ namespace NzbDrone.Core.Datastore.Migration
|
|||||||
{
|
{
|
||||||
if (profile.Items.Any(v => v.Quality == quality)) continue;
|
if (profile.Items.Any(v => v.Quality == quality)) continue;
|
||||||
|
|
||||||
profile.Items.Add(new ProfileItem70
|
profile.Items.Add(new ProfileItem71
|
||||||
{
|
{
|
||||||
Quality = quality,
|
Quality = quality,
|
||||||
Allowed = false
|
Allowed = false
|
||||||
@ -116,7 +117,7 @@ namespace NzbDrone.Core.Datastore.Migration
|
|||||||
|
|
||||||
var findIndex = profile.Items.FindIndex(v => v.Quality == find);
|
var findIndex = profile.Items.FindIndex(v => v.Quality == find);
|
||||||
|
|
||||||
profile.Items.Insert(findIndex, new ProfileItem70
|
profile.Items.Insert(findIndex, new ProfileItem71
|
||||||
{
|
{
|
||||||
Quality = quality,
|
Quality = quality,
|
||||||
Allowed = profile.Items[findIndex].Allowed
|
Allowed = profile.Items[findIndex].Allowed
|
||||||
@ -139,7 +140,7 @@ namespace NzbDrone.Core.Datastore.Migration
|
|||||||
|
|
||||||
var findIndex = profile.Items.FindIndex(v => v.Quality == find);
|
var findIndex = profile.Items.FindIndex(v => v.Quality == find);
|
||||||
|
|
||||||
profile.Items.Insert(findIndex + 1, new ProfileItem70
|
profile.Items.Insert(findIndex + 1, new ProfileItem71
|
||||||
{
|
{
|
||||||
Quality = quality,
|
Quality = quality,
|
||||||
Allowed = false
|
Allowed = false
|
||||||
@ -149,9 +150,9 @@ namespace NzbDrone.Core.Datastore.Migration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Profile70> GetProfiles()
|
private List<Profile71> GetProfiles()
|
||||||
{
|
{
|
||||||
var profiles = new List<Profile70>();
|
var profiles = new List<Profile71>();
|
||||||
|
|
||||||
using (var getProfilesCmd = _connection.CreateCommand())
|
using (var getProfilesCmd = _connection.CreateCommand())
|
||||||
{
|
{
|
||||||
@ -162,12 +163,12 @@ namespace NzbDrone.Core.Datastore.Migration
|
|||||||
{
|
{
|
||||||
while (profileReader.Read())
|
while (profileReader.Read())
|
||||||
{
|
{
|
||||||
profiles.Add(new Profile70
|
profiles.Add(new Profile71
|
||||||
{
|
{
|
||||||
Id = profileReader.GetInt32(0),
|
Id = profileReader.GetInt32(0),
|
||||||
Name = profileReader.GetString(1),
|
Name = profileReader.GetString(1),
|
||||||
Cutoff = profileReader.GetInt32(2),
|
Cutoff = profileReader.GetInt32(2),
|
||||||
Items = Json.Deserialize<List<ProfileItem70>>(profileReader.GetString(3)),
|
Items = Json.Deserialize<List<ProfileItem71>>(profileReader.GetString(3)),
|
||||||
Language = profileReader.GetInt32(4)
|
Language = profileReader.GetInt32(4)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using System.Data;
|
using System.Data;
|
||||||
using FluentMigrator;
|
using FluentMigrator;
|
||||||
using NzbDrone.Core.Datastore.Migration.Framework;
|
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ namespace NzbDrone.Core.Datastore.Migration
|
|||||||
|
|
||||||
private void ConvertProfile(IDbConnection conn, IDbTransaction tran)
|
private void ConvertProfile(IDbConnection conn, IDbTransaction tran)
|
||||||
{
|
{
|
||||||
var updater = new ProfileUpdater70(conn, tran);
|
var updater = new ProfileUpdater71(conn, tran);
|
||||||
updater.AppendQuality(16); // HDTV2160p
|
updater.AppendQuality(16); // HDTV2160p
|
||||||
updater.AppendQuality(18); // WEBDL2160p
|
updater.AppendQuality(18); // WEBDL2160p
|
||||||
updater.AppendQuality(19); // Bluray2160p
|
updater.AppendQuality(19); // Bluray2160p
|
||||||
|
@ -18,7 +18,7 @@ namespace NzbDrone.Core.Datastore.Migration
|
|||||||
|
|
||||||
private void ConvertProfile(IDbConnection conn, IDbTransaction tran)
|
private void ConvertProfile(IDbConnection conn, IDbTransaction tran)
|
||||||
{
|
{
|
||||||
var updater = new ProfileUpdater116(conn, tran);
|
var updater = new ProfileUpdater117(conn, tran);
|
||||||
|
|
||||||
updater.CreateGroupAt(8, 1000, "WEB 480p", new[] {12, 8}); // Group WEBRip480p with WEBDL480p
|
updater.CreateGroupAt(8, 1000, "WEB 480p", new[] {12, 8}); // Group WEBRip480p with WEBDL480p
|
||||||
updater.CreateGroupAt(2, 1001, "DVD", new[] {2, 13}); // Group Bluray480p with DVD
|
updater.CreateGroupAt(2, 1001, "DVD", new[] {2, 13}); // Group Bluray480p with DVD
|
||||||
@ -54,7 +54,7 @@ namespace NzbDrone.Core.Datastore.Migration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ProfileUpdater116
|
public class ProfileUpdater117
|
||||||
{
|
{
|
||||||
private readonly IDbConnection _connection;
|
private readonly IDbConnection _connection;
|
||||||
private readonly IDbTransaction _transaction;
|
private readonly IDbTransaction _transaction;
|
||||||
@ -62,7 +62,7 @@ namespace NzbDrone.Core.Datastore.Migration
|
|||||||
private List<Profile117> _profiles;
|
private List<Profile117> _profiles;
|
||||||
private HashSet<Profile117> _changedProfiles = new HashSet<Profile117>();
|
private HashSet<Profile117> _changedProfiles = new HashSet<Profile117>();
|
||||||
|
|
||||||
public ProfileUpdater116(IDbConnection conn, IDbTransaction tran)
|
public ProfileUpdater117(IDbConnection conn, IDbTransaction tran)
|
||||||
{
|
{
|
||||||
_connection = conn;
|
_connection = conn;
|
||||||
_transaction = tran;
|
_transaction = tran;
|
||||||
|
@ -0,0 +1,137 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
|
using System.Linq;
|
||||||
|
using FluentMigrator;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using NzbDrone.Common.Serializer;
|
||||||
|
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Datastore.Migration
|
||||||
|
{
|
||||||
|
[Migration(122)]
|
||||||
|
public class add_remux_qualities_in_profile : NzbDroneMigrationBase
|
||||||
|
{
|
||||||
|
protected override void MainDbUpgrade()
|
||||||
|
{
|
||||||
|
Execute.WithConnection(ConvertProfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ConvertProfile(IDbConnection conn, IDbTransaction tran)
|
||||||
|
{
|
||||||
|
var updater = new ProfileUpdater122(conn, tran);
|
||||||
|
|
||||||
|
// Insert 2060p, in case the user grouped Bluray 1080p and 2160p together.
|
||||||
|
|
||||||
|
updater.SplitQualityAppend(19, 21); // Bluray2160pRemux after Bluray2160p
|
||||||
|
updater.SplitQualityAppend(7, 20); // Bluray1080pRemux after Bluray1080p
|
||||||
|
|
||||||
|
updater.Commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Profile122
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public int Cutoff { get; set; }
|
||||||
|
public List<ProfileItem122> Items { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ProfileItem122
|
||||||
|
{
|
||||||
|
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public int? Quality { get; set; }
|
||||||
|
|
||||||
|
public bool Allowed { get; set; }
|
||||||
|
public List<ProfileItem122> Items { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ProfileUpdater122
|
||||||
|
{
|
||||||
|
private readonly IDbConnection _connection;
|
||||||
|
private readonly IDbTransaction _transaction;
|
||||||
|
|
||||||
|
private List<Profile122> _profiles;
|
||||||
|
private HashSet<Profile122> _changedProfiles = new HashSet<Profile122>();
|
||||||
|
|
||||||
|
public ProfileUpdater122(IDbConnection conn, IDbTransaction tran)
|
||||||
|
{
|
||||||
|
_connection = conn;
|
||||||
|
_transaction = tran;
|
||||||
|
|
||||||
|
_profiles = GetProfiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Commit()
|
||||||
|
{
|
||||||
|
foreach (var profile in _changedProfiles)
|
||||||
|
{
|
||||||
|
using (var updateProfileCmd = _connection.CreateCommand())
|
||||||
|
{
|
||||||
|
updateProfileCmd.Transaction = _transaction;
|
||||||
|
updateProfileCmd.CommandText = "UPDATE Profiles SET Name = ?, Cutoff = ?, Items = ? WHERE Id = ?";
|
||||||
|
updateProfileCmd.AddParameter(profile.Name);
|
||||||
|
updateProfileCmd.AddParameter(profile.Cutoff);
|
||||||
|
updateProfileCmd.AddParameter(profile.Items.ToJson());
|
||||||
|
updateProfileCmd.AddParameter(profile.Id);
|
||||||
|
|
||||||
|
updateProfileCmd.ExecuteNonQuery();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_changedProfiles.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SplitQualityAppend(int find, int quality)
|
||||||
|
{
|
||||||
|
foreach (var profile in _profiles)
|
||||||
|
{
|
||||||
|
if (profile.Items.Any(v => v.Quality == quality)) continue;
|
||||||
|
|
||||||
|
var findIndex = profile.Items.FindIndex(v =>
|
||||||
|
{
|
||||||
|
return v.Quality == find || (v.Items != null && v.Items.Any(b => b.Quality == find));
|
||||||
|
});
|
||||||
|
|
||||||
|
profile.Items.Insert(findIndex + 1, new ProfileItem122
|
||||||
|
{
|
||||||
|
Quality = quality,
|
||||||
|
Allowed = false
|
||||||
|
});
|
||||||
|
|
||||||
|
_changedProfiles.Add(profile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Profile122> GetProfiles()
|
||||||
|
{
|
||||||
|
var profiles = new List<Profile122>();
|
||||||
|
|
||||||
|
using (var getProfilesCmd = _connection.CreateCommand())
|
||||||
|
{
|
||||||
|
getProfilesCmd.Transaction = _transaction;
|
||||||
|
getProfilesCmd.CommandText = @"SELECT Id, Name, Cutoff, Items FROM Profiles";
|
||||||
|
|
||||||
|
using (var profileReader = getProfilesCmd.ExecuteReader())
|
||||||
|
{
|
||||||
|
while (profileReader.Read())
|
||||||
|
{
|
||||||
|
profiles.Add(new Profile122
|
||||||
|
{
|
||||||
|
Id = profileReader.GetInt32(0),
|
||||||
|
Name = profileReader.GetString(1),
|
||||||
|
Cutoff = profileReader.GetInt32(2),
|
||||||
|
Items = Json.Deserialize<List<ProfileItem122>>(profileReader.GetString(3))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return profiles;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -313,6 +313,7 @@
|
|||||||
<Compile Include="Datastore\Migration\111_create_language_profiles.cs" />
|
<Compile Include="Datastore\Migration\111_create_language_profiles.cs" />
|
||||||
<Compile Include="Datastore\Migration\115_add_downloadclient_status.cs" />
|
<Compile Include="Datastore\Migration\115_add_downloadclient_status.cs" />
|
||||||
<Compile Include="Datastore\Migration\121_update_animetosho_url.cs" />
|
<Compile Include="Datastore\Migration\121_update_animetosho_url.cs" />
|
||||||
|
<Compile Include="Datastore\Migration\122_add_remux_qualities_in_profile.cs" />
|
||||||
<Compile Include="Datastore\Migration\117_add_webrip_and_br480_qualites_in_profile.cs" />
|
<Compile Include="Datastore\Migration\117_add_webrip_and_br480_qualites_in_profile.cs" />
|
||||||
<Compile Include="Datastore\Migration\Framework\MigrationContext.cs" />
|
<Compile Include="Datastore\Migration\Framework\MigrationContext.cs" />
|
||||||
<Compile Include="Datastore\Migration\Framework\MigrationController.cs" />
|
<Compile Include="Datastore\Migration\Framework\MigrationController.cs" />
|
||||||
|
@ -49,10 +49,12 @@ namespace NzbDrone.Core.Parser
|
|||||||
|
|
||||||
private static readonly Regex OtherSourceRegex = new Regex(@"(?<hdtv>HD[-_. ]TV)|(?<sdtv>SD[-_. ]TV)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
private static readonly Regex OtherSourceRegex = new Regex(@"(?<hdtv>HD[-_. ]TV)|(?<sdtv>SD[-_. ]TV)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
private static readonly Regex AnimeBlurayRegex = new Regex(@"bd(?:720|1080)|(?<=[-_. (\[])bd(?=[-_. )\]])", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
private static readonly Regex AnimeBlurayRegex = new Regex(@"bd(?:720|1080|2160)|(?<=[-_. (\[])bd(?=[-_. )\]])", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
private static readonly Regex HighDefPdtvRegex = new Regex(@"hr[-_. ]ws", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
private static readonly Regex HighDefPdtvRegex = new Regex(@"hr[-_. ]ws", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
|
private static readonly Regex RemuxRegex = new Regex(@"\b(?<remux>(BD)?[-_. ]?Remux)\b", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
public static QualityModel ParseQuality(string name)
|
public static QualityModel ParseQuality(string name)
|
||||||
{
|
{
|
||||||
Logger.Debug("Trying to parse quality for {0}", name);
|
Logger.Debug("Trying to parse quality for {0}", name);
|
||||||
@ -61,7 +63,7 @@ namespace NzbDrone.Core.Parser
|
|||||||
|
|
||||||
var result = ParseQualityName(name);
|
var result = ParseQualityName(name);
|
||||||
|
|
||||||
//Based on extension
|
// Based on extension
|
||||||
if (result.Quality == Quality.Unknown && !name.ContainsInvalidPathChars())
|
if (result.Quality == Quality.Unknown && !name.ContainsInvalidPathChars())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -71,8 +73,8 @@ namespace NzbDrone.Core.Parser
|
|||||||
}
|
}
|
||||||
catch (ArgumentException)
|
catch (ArgumentException)
|
||||||
{
|
{
|
||||||
//Swallow exception for cases where string contains illegal
|
// Swallow exception for cases where string contains illegal
|
||||||
//path characters.
|
// path characters.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,6 +95,7 @@ namespace NzbDrone.Core.Parser
|
|||||||
var sourceMatch = SourceRegex.Matches(normalizedName).OfType<Match>().LastOrDefault();
|
var sourceMatch = SourceRegex.Matches(normalizedName).OfType<Match>().LastOrDefault();
|
||||||
var resolution = ParseResolution(normalizedName);
|
var resolution = ParseResolution(normalizedName);
|
||||||
var codecRegex = CodecRegex.Match(normalizedName);
|
var codecRegex = CodecRegex.Match(normalizedName);
|
||||||
|
var remuxMatch = RemuxRegex.IsMatch(normalizedName);
|
||||||
|
|
||||||
if (sourceMatch != null && sourceMatch.Success)
|
if (sourceMatch != null && sourceMatch.Success)
|
||||||
{
|
{
|
||||||
@ -106,13 +109,14 @@ namespace NzbDrone.Core.Parser
|
|||||||
|
|
||||||
if (resolution == Resolution.R2160p)
|
if (resolution == Resolution.R2160p)
|
||||||
{
|
{
|
||||||
result.Quality = Quality.Bluray2160p;
|
result.Quality = remuxMatch ? Quality.Bluray2160pRemux : Quality.Bluray2160p;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resolution == Resolution.R1080p)
|
if (resolution == Resolution.R1080p)
|
||||||
{
|
{
|
||||||
result.Quality = Quality.Bluray1080p;
|
result.Quality = remuxMatch ? Quality.Bluray1080pRemux : Quality.Bluray1080p;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,6 +126,13 @@ namespace NzbDrone.Core.Parser
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Treat a remux without a source as 1080p, not 720p.
|
||||||
|
if (remuxMatch)
|
||||||
|
{
|
||||||
|
result.Quality = Quality.Bluray1080pRemux;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
result.Quality = Quality.Bluray720p;
|
result.Quality = Quality.Bluray720p;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -262,7 +273,7 @@ namespace NzbDrone.Core.Parser
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Anime Bluray matching
|
// Anime Bluray matching
|
||||||
if (AnimeBlurayRegex.Match(normalizedName).Success)
|
if (AnimeBlurayRegex.Match(normalizedName).Success)
|
||||||
{
|
{
|
||||||
if (resolution == Resolution.R480P || resolution == Resolution.R576p || normalizedName.Contains("480p"))
|
if (resolution == Resolution.R480P || resolution == Resolution.R576p || normalizedName.Contains("480p"))
|
||||||
@ -272,6 +283,19 @@ namespace NzbDrone.Core.Parser
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (resolution == Resolution.R1080p || normalizedName.Contains("1080p"))
|
if (resolution == Resolution.R1080p || normalizedName.Contains("1080p"))
|
||||||
|
{
|
||||||
|
result.Quality = remuxMatch ? Quality.Bluray1080pRemux : Quality.Bluray1080p;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resolution == Resolution.R2160p || normalizedName.Contains("2160p"))
|
||||||
|
{
|
||||||
|
result.Quality = remuxMatch ? Quality.Bluray2160pRemux : Quality.Bluray2160p;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Treat a remux without a source as 1080p, not 720p.
|
||||||
|
if (remuxMatch)
|
||||||
{
|
{
|
||||||
result.Quality = Quality.Bluray1080p;
|
result.Quality = Quality.Bluray1080p;
|
||||||
return result;
|
return result;
|
||||||
@ -283,13 +307,13 @@ namespace NzbDrone.Core.Parser
|
|||||||
|
|
||||||
if (resolution == Resolution.R2160p)
|
if (resolution == Resolution.R2160p)
|
||||||
{
|
{
|
||||||
result.Quality = Quality.HDTV2160p;
|
result.Quality = remuxMatch ? Quality.Bluray2160pRemux : Quality.HDTV2160p;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resolution == Resolution.R1080p)
|
if (resolution == Resolution.R1080p)
|
||||||
{
|
{
|
||||||
result.Quality = Quality.HDTV1080p;
|
result.Quality = remuxMatch ? Quality.Bluray1080pRemux : Quality.HDTV1080p;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,6 +375,11 @@ namespace NzbDrone.Core.Parser
|
|||||||
result.Quality = Quality.Bluray1080p;
|
result.Quality = Quality.Bluray1080p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (normalizedName.Contains("bluray2160p"))
|
||||||
|
{
|
||||||
|
result.Quality = Quality.Bluray2160p;
|
||||||
|
}
|
||||||
|
|
||||||
var otherSourceMatch = OtherSourceMatch(normalizedName);
|
var otherSourceMatch = OtherSourceMatch(normalizedName);
|
||||||
|
|
||||||
if (otherSourceMatch != Quality.Unknown)
|
if (otherSourceMatch != Quality.Unknown)
|
||||||
@ -402,8 +431,8 @@ namespace NzbDrone.Core.Parser
|
|||||||
result.Revision.Version = Convert.ToInt32(versionRegexResult.Groups["version"].Value);
|
result.Revision.Version = Convert.ToInt32(versionRegexResult.Groups["version"].Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: re-enable this when we have a reliable way to determine real
|
// TODO: re-enable this when we have a reliable way to determine real
|
||||||
//TODO: Only treat it as a real if it comes AFTER the season/epsiode number
|
// TODO: Only treat it as a real if it comes AFTER the season/epsiode number
|
||||||
var realRegexResult = RealRegex.Matches(name);
|
var realRegexResult = RealRegex.Matches(name);
|
||||||
|
|
||||||
if (realRegexResult.Count > 0)
|
if (realRegexResult.Count > 0)
|
||||||
|
@ -79,6 +79,8 @@ namespace NzbDrone.Core.Qualities
|
|||||||
public static Quality WEBRip2160p { get { return new Quality(17, "WEBRip-2160p", QualitySource.WebRip, 2160); } }
|
public static Quality WEBRip2160p { get { return new Quality(17, "WEBRip-2160p", QualitySource.WebRip, 2160); } }
|
||||||
public static Quality WEBDL2160p => new Quality(18, "WEBDL-2160p", QualitySource.Web, 2160);
|
public static Quality WEBDL2160p => new Quality(18, "WEBDL-2160p", QualitySource.Web, 2160);
|
||||||
public static Quality Bluray2160p => new Quality(19, "Bluray-2160p", QualitySource.Bluray, 2160);
|
public static Quality Bluray2160p => new Quality(19, "Bluray-2160p", QualitySource.Bluray, 2160);
|
||||||
|
public static Quality Bluray1080pRemux => new Quality(20, "Bluray-1080p Remux", QualitySource.BlurayRaw, 1080);
|
||||||
|
public static Quality Bluray2160pRemux => new Quality(21, "Bluray-2160p Remux", QualitySource.BlurayRaw, 2160);
|
||||||
|
|
||||||
static Quality()
|
static Quality()
|
||||||
{
|
{
|
||||||
@ -102,7 +104,9 @@ namespace NzbDrone.Core.Qualities
|
|||||||
HDTV2160p,
|
HDTV2160p,
|
||||||
WEBRip2160p,
|
WEBRip2160p,
|
||||||
WEBDL2160p,
|
WEBDL2160p,
|
||||||
Bluray2160p
|
Bluray2160p,
|
||||||
|
Bluray1080pRemux,
|
||||||
|
Bluray2160pRemux
|
||||||
};
|
};
|
||||||
|
|
||||||
AllLookup = new Quality[All.Select(v => v.Id).Max() + 1];
|
AllLookup = new Quality[All.Select(v => v.Id).Max() + 1];
|
||||||
@ -128,10 +132,12 @@ namespace NzbDrone.Core.Qualities
|
|||||||
new QualityDefinition(Quality.WEBRip1080p) { Weight = 11, MinSize = 0, MaxSize = 100, GroupName = "WEB 1080p" },
|
new QualityDefinition(Quality.WEBRip1080p) { Weight = 11, MinSize = 0, MaxSize = 100, GroupName = "WEB 1080p" },
|
||||||
new QualityDefinition(Quality.WEBDL1080p) { Weight = 11, MinSize = 0, MaxSize = 100, GroupName = "WEB 1080p" },
|
new QualityDefinition(Quality.WEBDL1080p) { Weight = 11, MinSize = 0, MaxSize = 100, GroupName = "WEB 1080p" },
|
||||||
new QualityDefinition(Quality.Bluray1080p) { Weight = 12, MinSize = 0, MaxSize = 100 },
|
new QualityDefinition(Quality.Bluray1080p) { Weight = 12, MinSize = 0, MaxSize = 100 },
|
||||||
new QualityDefinition(Quality.HDTV2160p) { Weight = 13, MinSize = 0, MaxSize = null },
|
new QualityDefinition(Quality.Bluray1080pRemux) { Weight = 13, MinSize = 0, MaxSize = null },
|
||||||
new QualityDefinition(Quality.WEBRip2160p) { Weight = 14, MinSize = 0, MaxSize = null, GroupName = "WEB 2160p" },
|
new QualityDefinition(Quality.HDTV2160p) { Weight = 14, MinSize = 0, MaxSize = null },
|
||||||
new QualityDefinition(Quality.WEBDL2160p) { Weight = 14, MinSize = 0, MaxSize = null, GroupName = "WEB 2160p" },
|
new QualityDefinition(Quality.WEBRip2160p) { Weight = 15, MinSize = 0, MaxSize = null, GroupName = "WEB 2160p" },
|
||||||
new QualityDefinition(Quality.Bluray2160p) { Weight = 15, MinSize = 0, MaxSize = null }
|
new QualityDefinition(Quality.WEBDL2160p) { Weight = 15, MinSize = 0, MaxSize = null, GroupName = "WEB 2160p" },
|
||||||
|
new QualityDefinition(Quality.Bluray2160p) { Weight = 16, MinSize = 0, MaxSize = null },
|
||||||
|
new QualityDefinition(Quality.Bluray2160pRemux) { Weight = 17, MinSize = 0, MaxSize = null }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ namespace NzbDrone.Core.Qualities
|
|||||||
Web,
|
Web,
|
||||||
WebRip,
|
WebRip,
|
||||||
DVD,
|
DVD,
|
||||||
Bluray
|
Bluray,
|
||||||
|
BlurayRaw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user