Decompiled source of TelevisionVideosFix v0.0.3

TelevisionVideosFix.dll

Decompiled 9 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace TelevisionVideosFix
{
	[BepInPlugin("TelevisionVideosFix", "TelevisionVideosFix", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private string TelevisionVideosPluginPath => Path.Combine(Paths.PluginPath, "Television Videos");

		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin TelevisionVideosFix is loaded!");
			CreatePluginTelevisionVideosFolder();
			SearchAndMoveTelevisionVideos();
			MoveVideoFiles();
		}

		private void CreatePluginTelevisionVideosFolder()
		{
			if (!Directory.Exists(TelevisionVideosPluginPath))
			{
				Directory.CreateDirectory(TelevisionVideosPluginPath);
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Created 'Television Videos' folder in plugin directory.");
			}
		}

		private void MoveVideoFiles()
		{
			if (!Directory.Exists(TelevisionVideosPluginPath))
			{
				Directory.CreateDirectory(TelevisionVideosPluginPath);
			}
			IEnumerable<string> files = Directory.GetFiles(TelevisionVideosPluginPath, "*.mp4");
			foreach (string item in files)
			{
				string fileName = Path.GetFileName(item);
				string text = Path.Combine(TelevisionVideosPluginPath, fileName);
				if (!File.Exists(text))
				{
					File.Move(item, text);
					((BaseUnityPlugin)this).Logger.LogInfo((object)("Moved " + fileName + " to Television Videos folder."));
				}
			}
		}

		private void SearchAndMoveTelevisionVideos()
		{
			string[] directories = Directory.GetDirectories(Paths.PluginPath);
			string[] array = directories;
			foreach (string path in array)
			{
				string text = Path.Combine(path, "Television Videos");
				if (!Directory.Exists(text))
				{
					continue;
				}
				IEnumerable<string> files = Directory.GetFiles(text, "*.mp4");
				foreach (string item in files)
				{
					string fileName = Path.GetFileName(item);
					string text2 = Path.Combine(TelevisionVideosPluginPath, fileName);
					if (!File.Exists(text2))
					{
						File.Move(item, text2);
						((BaseUnityPlugin)this).Logger.LogInfo((object)("Moved " + fileName + " from " + text + " to Television Videos folder."));
					}
				}
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}