mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 21:43:33 -07:00
SceneMapping will use the JSON API instead of CSV file now.
This commit is contained in:
parent
42554b815a
commit
afb8305c00
6 changed files with 50 additions and 40 deletions
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using NLog;
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using PetaPoco;
|
||||
|
@ -29,32 +30,16 @@ namespace NzbDrone.Core.Providers
|
|||
{
|
||||
try
|
||||
{
|
||||
var mapping = _httpProvider.DownloadString("http://www.nzbdrone.com/SceneMappings.csv");
|
||||
var newMaps = new List<SceneMapping>();
|
||||
|
||||
using (var reader = new StringReader(mapping))
|
||||
{
|
||||
string line;
|
||||
while ((line = reader.ReadLine()) != null)
|
||||
{
|
||||
var split = line.Split(',');
|
||||
int seriesId;
|
||||
Int32.TryParse(split[1], out seriesId);
|
||||
|
||||
var map = new SceneMapping();
|
||||
map.CleanTitle = split[0];
|
||||
map.SeriesId = seriesId;
|
||||
map.SceneName = split[2];
|
||||
|
||||
newMaps.Add(map);
|
||||
}
|
||||
}
|
||||
const string url = "http://services.nzbdrone.com/SceneMapping/Active";
|
||||
|
||||
var mappingsJson = _httpProvider.DownloadString(url);
|
||||
var mappings = JsonConvert.DeserializeObject<List<SceneMapping>>(mappingsJson);
|
||||
|
||||
Logger.Debug("Deleting all existing Scene Mappings.");
|
||||
_database.Delete<SceneMapping>(String.Empty);
|
||||
|
||||
Logger.Debug("Adding Scene Mappings");
|
||||
_database.InsertMany(newMaps);
|
||||
_database.InsertMany(mappings);
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue