-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #450 from TV-Rename/code-tidy
Many Updates
- Loading branch information
Showing
43 changed files
with
2,511 additions
and
1,644 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:String x:Key="/Default/CodeInspection/Highlighting/AnalysisEnabled/@EntryValue">SOLUTION</s:String></wpf:ResourceDictionary> | ||
<s:String x:Key="/Default/CodeInspection/Highlighting/AnalysisEnabled/@EntryValue">SOLUTION</s:String> | ||
<s:String x:Key="/Default/Profiling/Configurations/=0/@EntryIndexedValue"><data><HostParameters type="LocalHostParameters" /><Argument type="AttachArgument"><DisplayName>C:\Users\Mark\source\repos\TV-Rename\tvrename-master\TVRename\bin\Debug\TVRename.exe</DisplayName><ProcessId>30360</ProcessId><RuntimeVersion>4.0.30319</RuntimeVersion></Argument><Info type="TimelineInfo" /><CoreOptions type="CoreOptions"><CoreTempPath IsNull="False"></CoreTempPath><RemoteEndPoint IsNull="False"></RemoteEndPoint><AdditionalEnvironmentVariables /></CoreOptions><HostOptions type="HostOptions"><HostTempPath IsNull="False"></HostTempPath></HostOptions></data></s:String> | ||
<s:String x:Key="/Default/Profiling/Configurations/=1/@EntryIndexedValue"><data><HostParameters type="LocalHostParameters" /><Argument type="StandaloneArgument"><Arguments IsNull="False"></Arguments><FileName IsNull="False"></FileName><WorkingDirectory IsNull="False"></WorkingDirectory><Scope><ProcessFilters /></Scope></Argument><Info type="TimelineInfo" /><CoreOptions type="CoreOptions"><CoreTempPath IsNull="False"></CoreTempPath><RemoteEndPoint IsNull="False"></RemoteEndPoint><AdditionalEnvironmentVariables /></CoreOptions><HostOptions type="HostOptions"><HostTempPath IsNull="False"></HostTempPath></HostOptions></data></s:String> | ||
</wpf:ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,5 @@ private static string CreateHtml(ShowItem si) | |
</div> | ||
</div></div></div>"; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Ical.Net; | ||
using Ical.Net.CalendarComponents; | ||
using Ical.Net.DataTypes; | ||
using Ical.Net.Serialization; | ||
|
||
namespace TVRename | ||
{ | ||
// ReSharper disable once InconsistentNaming | ||
internal class UpcomingiCAL :UpcomingExporter | ||
{ | ||
public UpcomingiCAL(TVDoc i) : base(i) { } | ||
public override bool Active() =>TVSettings.Instance.ExportWTWICAL; | ||
protected override string Location() => TVSettings.Instance.ExportWTWICALTo; | ||
|
||
protected override bool Generate(System.IO.Stream str, List<ProcessedEpisode> elist) | ||
{ | ||
if (elist == null) | ||
return false; | ||
|
||
try | ||
{ | ||
Calendar calendar = new Calendar {ProductId = "Upcoming Shows Exported by TV Rename http://www.tvrename.com"}; | ||
|
||
foreach (ProcessedEpisode ei in elist) | ||
{ | ||
string niceName = TVSettings.Instance.NamingStyle.NameFor(ei); | ||
DateTime? stTime = ei.GetAirDateDT(true); | ||
|
||
if (!stTime.HasValue) continue; | ||
|
||
DateTime startTime = stTime.Value; | ||
String s = ei.SI.TheSeries().GetRuntime(); | ||
DateTime endTime = stTime.Value.AddMinutes(int.Parse(s)); | ||
|
||
CalendarEvent e = new CalendarEvent | ||
{ | ||
Start = new CalDateTime(startTime), | ||
End = new CalDateTime(endTime), | ||
Description = ei.Overview, | ||
Comments = new List<string>{ei.Overview}, | ||
Summary = niceName, | ||
Location=ei.TheSeries.GetNetwork(), | ||
Url = new Uri(TheTVDB.Instance.WebsiteUrl(ei.TheSeries.TVDBCode, ei.SeasonId, false)), | ||
Uid = ei.EpisodeId.ToString() | ||
}; | ||
calendar.Events.Add(e); | ||
} | ||
|
||
CalendarSerializer serializer = new CalendarSerializer(); | ||
serializer.Serialize(calendar,str,Encoding.ASCII); | ||
|
||
return true; | ||
} // try | ||
catch (Exception e) | ||
{ | ||
Logger.Error(e); | ||
return false; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Alphaleonis.Win32.Filesystem; | ||
|
||
namespace TVRename | ||
{ | ||
internal abstract class TorrentFinder : Finder | ||
{ | ||
public override FinderDisplayType DisplayType() => FinderDisplayType.downloading; | ||
|
||
protected void SearchForAppropriateDownloads(SetProgressDelegate prog, int startpct, int totPct, List<TorrentEntry> downloading) | ||
{ | ||
ItemList newList = new ItemList(); | ||
ItemList toRemove = new ItemList(); | ||
int c = ActionList.Count + 2; | ||
int n = 1; | ||
prog.Invoke(startpct); | ||
foreach (Item action1 in ActionList) | ||
{ | ||
if (ActionCancel) | ||
return; | ||
|
||
prog.Invoke(startpct + ((totPct - startpct) * (++n) / (c))); | ||
|
||
if (!(action1 is ItemMissing action)) | ||
continue; | ||
|
||
foreach (TorrentEntry te in downloading) | ||
{ | ||
FileInfo file = new FileInfo(te.DownloadingTo); | ||
if (!TVSettings.Instance.UsefulExtension(file.Extension, false)) // not a usefile file extension | ||
continue; | ||
|
||
//do any of the possible names for the series match the filename? | ||
bool matched = (action.Episode.SI.GetSimplifiedPossibleShowNames().Any(name => FileHelper.SimplifyAndCheckFilename(file.FullName, name))); | ||
|
||
if (!matched) continue; | ||
|
||
if (TVDoc.FindSeasEp(file, out int seasF, out int epF, out int _, action.Episode.SI) && (seasF == action.Episode.AppropriateSeasonNumber) && (epF == action.Episode.AppropriateEpNum)) | ||
{ | ||
toRemove.Add(action1); | ||
newList.Add(new ItemuTorrenting(te, action.Episode, action.TheFileNoExt)); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
foreach (Item i in toRemove) | ||
ActionList.Remove(i); | ||
|
||
foreach (Item action in newList) | ||
ActionList.Add(action); | ||
|
||
prog.Invoke(totPct); | ||
} | ||
|
||
protected TorrentFinder(TVDoc doc) : base(doc) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using Newtonsoft.Json.Linq; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace TVRename | ||
{ | ||
// ReSharper disable once InconsistentNaming | ||
internal class qBitTorrentFinder : TorrentFinder | ||
{ | ||
public qBitTorrentFinder(TVDoc i) : base(i) { } | ||
public override bool Active() => TVSettings.Instance.CheckqBitTorrent; | ||
|
||
public override void Check(SetProgressDelegate prog, int startpct, int totPct) | ||
{ | ||
List<TorrentEntry> downloading = GetqBitTorrentDownloads(); | ||
SearchForAppropriateDownloads(prog, startpct, totPct, downloading); | ||
} | ||
|
||
private static List<TorrentEntry> GetqBitTorrentDownloads() | ||
{ | ||
List < TorrentEntry > ret = new List<TorrentEntry>(); | ||
|
||
// get list of files being downloaded by qBitTorrentFinder | ||
string host = TVSettings.Instance.qBitTorrentHost; | ||
string port = TVSettings.Instance.qBitTorrentPort; | ||
if (string.IsNullOrEmpty(host) || string.IsNullOrEmpty(port)) | ||
return ret; | ||
|
||
string url = $"http://{host}:{port}/query/"; | ||
|
||
JToken settings = JsonHelper.ObtainToken(url + "preferences"); | ||
JArray currentDownloads = JsonHelper.ObtainArray(url + "torrents?filter=all"); | ||
|
||
foreach (JToken torrent in currentDownloads.Children()) | ||
{ | ||
JArray stuff2 = JsonHelper.ObtainArray(url + "propertiesFiles/" + torrent["hash"]); | ||
|
||
foreach (JToken file in stuff2.Children()) | ||
{ | ||
ret.Add(new TorrentEntry(torrent["name"].ToString(), settings["save_path"] + file["name"].ToString(), (int)(100 * file["progress"].ToObject<float>()))); | ||
} | ||
|
||
if (!stuff2.Children().Any()) | ||
{ | ||
ret.Add(new TorrentEntry(torrent["name"].ToString(), settings["save_path"] + torrent["name"].ToString() + TVSettings.Instance.VideoExtensionsArray[0], 0)); | ||
} | ||
} | ||
|
||
return ret; | ||
} | ||
} | ||
} |
Oops, something went wrong.