new history-filter option added
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
- Support multiple folders input (regression fix).
|
||||
- Relative file input paths are converted to absolute paths.
|
||||
- New history-filter option added to define paths to be excluded from the history log feature.
|
||||
|
||||
|
||||
# 6.0.3.1 (2022-07-30)
|
||||
|
||||
@@ -505,6 +505,10 @@ Amount of recent files to be remembered. Default: 15
|
||||
|
||||
Usage of the media info library instead of mpv to access media information. Default: yes (mpv.net specific option)
|
||||
|
||||
#### --history-filter
|
||||
|
||||
Semicolon separated list of paths to be excluded from the history log feature.
|
||||
|
||||
#### --video-file-extensions=\<string\>
|
||||
|
||||
Video file extensions used to create file associations and used by the auto-load-folder feature.
|
||||
|
||||
@@ -14,6 +14,8 @@ namespace mpvnet
|
||||
{
|
||||
public static List<string> TempFiles { get; } = new List<string>();
|
||||
|
||||
public static string[] HistoryFilter { get; set; }
|
||||
|
||||
public static string ConfPath { get => Core.ConfigFolder + "mpvnet.conf"; }
|
||||
public static string ProcessInstance { get; set; } = "single";
|
||||
public static string DarkMode { get; set; } = "always";
|
||||
@@ -244,16 +246,17 @@ namespace mpvnet
|
||||
case "audio-file-extensions": CorePlayer.AudioTypes = value.Split(" ,;".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); return true;
|
||||
case "auto-load-folder": AutoLoadFolder = value == "yes"; return true;
|
||||
case "auto-play": AutoPlay = value == "yes"; return true;
|
||||
case "autofit-image": AutofitImage = value.Trim('%').ToInt() / 100f; return true;
|
||||
case "autofit-audio": AutofitAudio = value.Trim('%').ToInt() / 100f; return true;
|
||||
case "autofit-image": AutofitImage = value.Trim('%').ToInt() / 100f; return true;
|
||||
case "dark-mode": DarkMode = value; return true;
|
||||
case "dark-theme": DarkTheme = value.Trim('\'', '"'); return true;
|
||||
case "debug-mode": DebugMode = value == "yes"; return true;
|
||||
case "history-filter": HistoryFilter = value.Split(';'); return true;
|
||||
case "image-file-extensions": CorePlayer.ImageTypes = value.Split(" ,;".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); return true;
|
||||
case "light-theme": LightTheme = value.Trim('\'', '"'); return true;
|
||||
case "media-info": MediaInfo = value == "yes"; return true;
|
||||
case "minimum-aspect-ratio": MinimumAspectRatio = value.ToFloat(); return true;
|
||||
case "minimum-aspect-ratio-audio": MinimumAspectRatioAudio = value.ToFloat(); return true;
|
||||
case "minimum-aspect-ratio": MinimumAspectRatio = value.ToFloat(); return true;
|
||||
case "process-instance": ProcessInstance = value; return true;
|
||||
case "queue": Queue = value == "yes"; return true;
|
||||
case "recent-count": RecentCount = value.ToInt(); return true;
|
||||
@@ -264,6 +267,7 @@ namespace mpvnet
|
||||
case "start-size": StartSize = value; return true;
|
||||
case "start-threshold": StartThreshold = value.ToInt(); return true;
|
||||
case "video-file-extensions": CorePlayer.VideoTypes = value.Split(" ,;".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); return true;
|
||||
|
||||
default:
|
||||
if (writeError)
|
||||
Terminal.WriteError($"unknown mpvnet.conf property: {name}");
|
||||
|
||||
@@ -157,8 +157,8 @@ namespace mpvnet
|
||||
ProcessHelp.ShellExecute(Core.ConfigFolder + "history.txt");
|
||||
else
|
||||
{
|
||||
if (Msg.ShowQuestion("Create history.txt file in config folder?" + BR2 +
|
||||
"mpv.net will write the date, time and filename of opened files to it.") == MessageBoxResult.OK)
|
||||
if (Msg.ShowQuestion("Create a 'history.txt' file in the config folder?" + BR2 +
|
||||
"mpv.net will write the date, time, play length and path of watched files to it.") == MessageBoxResult.OK)
|
||||
|
||||
File.WriteAllText(Core.ConfigFolder + "history.txt", "");
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ namespace mpvnet
|
||||
|
||||
public AutoResetEvent ShutdownAutoResetEvent { get; } = new AutoResetEvent(false);
|
||||
public AutoResetEvent VideoSizeAutoResetEvent { get; } = new AutoResetEvent(false);
|
||||
public DateTime HistoryTime;
|
||||
public IntPtr Handle { get; set; }
|
||||
public IntPtr NamedHandle { get; set; }
|
||||
public List<MediaTrack> MediaTracks { get; set; } = new List<MediaTrack>();
|
||||
@@ -176,7 +177,15 @@ namespace mpvnet
|
||||
SetPropertyString("idle", "yes");
|
||||
|
||||
ObservePropertyDouble("window-scale", value => WindowScaleMpv(value));
|
||||
ObservePropertyString("path", value => Path = value);
|
||||
|
||||
ObservePropertyString("path", value => {
|
||||
if (HistoryTime == DateTime.MinValue)
|
||||
{
|
||||
HistoryTime = DateTime.Now;
|
||||
HistoryPath = value;
|
||||
}
|
||||
Path = value;
|
||||
});
|
||||
|
||||
ObservePropertyBool("pause", value => {
|
||||
Paused = value;
|
||||
@@ -499,7 +508,7 @@ namespace mpvnet
|
||||
case mpv_event_id.MPV_EVENT_SHUTDOWN:
|
||||
IsQuitNeeded = false;
|
||||
Shutdown?.Invoke();
|
||||
WriteHistory(null);
|
||||
WriteHistory();
|
||||
ShutdownAutoResetEvent.Set();
|
||||
return;
|
||||
case mpv_event_id.MPV_EVENT_LOG_MESSAGE:
|
||||
@@ -580,13 +589,7 @@ namespace mpvnet
|
||||
}
|
||||
|
||||
App.RunTask(new Action(() => UpdateTracks()));
|
||||
|
||||
App.RunTask(new Action(() => {
|
||||
if (path.Contains("://"))
|
||||
path = GetPropertyString("media-title");
|
||||
|
||||
WriteHistory(path);
|
||||
}));
|
||||
App.RunTask(new Action(() => WriteHistory()));
|
||||
|
||||
InvokeEvent(FileLoaded, FileLoadedAsync);
|
||||
}
|
||||
@@ -942,29 +945,6 @@ namespace mpvnet
|
||||
return "";
|
||||
}
|
||||
|
||||
public string GetScriptOption(string name, string defaultValue = "")
|
||||
{
|
||||
string value = GetPropertyString("script-opts");
|
||||
|
||||
if (string.IsNullOrEmpty(value))
|
||||
return defaultValue;
|
||||
|
||||
string[] values = value.Split(',');
|
||||
|
||||
foreach (string item in values)
|
||||
{
|
||||
if (item.Contains("="))
|
||||
{
|
||||
string optionName = item.Substring(0, item.IndexOf("="));
|
||||
|
||||
if (optionName == name)
|
||||
return item.Substring(item.IndexOf("=") + 1);
|
||||
}
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public void ObservePropertyInt(string name, Action<int> action)
|
||||
{
|
||||
lock (IntPropChangeActions)
|
||||
@@ -1369,38 +1349,36 @@ namespace mpvnet
|
||||
}
|
||||
}
|
||||
|
||||
string LastHistoryPath;
|
||||
DateTime LastHistoryStartDateTime;
|
||||
string HistoryPath;
|
||||
|
||||
void WriteHistory(string path)
|
||||
void WriteHistory()
|
||||
{
|
||||
if (!File.Exists(ConfigFolder + "history.txt"))
|
||||
return;
|
||||
double totalMinutes = (DateTime.Now - HistoryTime).TotalMinutes;
|
||||
|
||||
double totalMinutes = (DateTime.Now - LastHistoryStartDateTime).TotalMinutes;
|
||||
if (!string.IsNullOrEmpty(HistoryPath) && totalMinutes > 1 &&
|
||||
!HistoryDiscard() && File.Exists(ConfigFolder + "history.txt"))
|
||||
{
|
||||
string path = HistoryPath;
|
||||
|
||||
if (LastHistoryPath != null && totalMinutes > 1 && !HistoryDiscard())
|
||||
File.AppendAllText(ConfigFolder + "history.txt", DateTime.Now.ToString().Substring(0, 16) +
|
||||
" " + Convert.ToInt32(totalMinutes).ToString().PadLeft(3) + " " + LastHistoryPath + "\r\n");
|
||||
if (path.Contains("://"))
|
||||
path = GetPropertyString("media-title");
|
||||
|
||||
LastHistoryPath = path;
|
||||
LastHistoryStartDateTime = DateTime.Now;
|
||||
string txt = DateTime.Now.ToString().Substring(0, 16) + " " +
|
||||
Convert.ToInt32(totalMinutes).ToString().PadLeft(3) + " " + path + "\r\n";
|
||||
|
||||
File.AppendAllText(ConfigFolder + "history.txt", txt);
|
||||
}
|
||||
|
||||
HistoryPath = Path;
|
||||
HistoryTime = DateTime.Now;
|
||||
}
|
||||
|
||||
string HistoryDiscardOption;
|
||||
|
||||
bool HistoryDiscard()
|
||||
public bool HistoryDiscard()
|
||||
{
|
||||
if (HistoryDiscardOption == null)
|
||||
HistoryDiscardOption = GetScriptOption("history-discard");
|
||||
|
||||
if (string.IsNullOrEmpty(HistoryDiscardOption))
|
||||
return false;
|
||||
|
||||
foreach (string i in HistoryDiscardOption.Split(';'))
|
||||
if (LastHistoryPath.Contains(i))
|
||||
return true;
|
||||
|
||||
if (App.HistoryFilter != null)
|
||||
foreach (string filter in App.HistoryFilter)
|
||||
if (HistoryPath.Contains(filter.Trim()))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,13 @@ help = Usage of the media info library instead of mpv to access media informatio
|
||||
option = yes
|
||||
option = no
|
||||
|
||||
[setting]
|
||||
name = history-filter
|
||||
file = mpvnet
|
||||
filter = General
|
||||
width = 500
|
||||
help = Semicolon separated list of paths to be excluded from the history log feature.
|
||||
|
||||
[setting]
|
||||
name = video-file-extensions
|
||||
file = mpvnet
|
||||
|
||||
@@ -779,7 +779,7 @@ namespace mpvnet
|
||||
|
||||
string text = Core.Expand(title);
|
||||
|
||||
if (text == "(unavailable)")
|
||||
if (text == "(unavailable)" || Core.PlaylistPos == -1)
|
||||
text = "mpv.net";
|
||||
|
||||
Text = text;
|
||||
|
||||
Reference in New Issue
Block a user