This file contains hidden or 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
| using System; | |
| using System.Collections.Generic; | |
| using System.Diagnostics; | |
| using System.Globalization; | |
| using System.IO; | |
| using System.Linq; | |
| using System.Text; | |
| using System.Text.RegularExpressions; | |
| using System.Threading; | |
| using System.Threading.Tasks; |
This file contains hidden or 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
| using MySql.Data.MySqlClient; | |
| namespace MediaProviderWorker.Helpers.Database | |
| { | |
| class MysqlConnectionData | |
| { | |
| public string Server { get { return _server; }set { _server = value; } } | |
| public string Port { get { return _port; }set { _port = value; } } | |
| public string Db { get { return _db; }set { _db = value; } } |
This file contains hidden or 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
| class YTitleIDCollection | |
| { | |
| public string videoId { get; set; } | |
| public string title { get; set; } | |
| } | |
| class JSON_PlaylistItems | |
| { | |
| public string nextPageToken; | |
| public Item[] items; |
This file contains hidden or 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
| class YoutubeProvider | |
| { | |
| public float percentage { get; set; } | |
| public string size { get; set; } = string.Empty; | |
| public string speed { get; set; } = string.Empty; | |
| public TimeSpan eta { get; set; } | |
| public string rawResponse { get; set; } = string.Empty; | |
| public bool hasFinished { get; private set; } | |
| public string saveto { get; private set; } = string.Empty; |
This file contains hidden or 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
| public static void use(string[] args) | |
| { | |
| var dat = new YoutubeProvider(args.Length != 0 ? args[0] : "https://www.youtube.com/watch?v=IxuEtL7gxoM"); | |
| var dat1 = new YoutubeProvider(args.Length > 1 ? args[1] : "https://www.youtube.com/watch?v=VmUGe8KDdGI"); | |
| while (!dat.hasFinished || !dat1.hasFinished) | |
| { | |
| WaitHandle.WaitAny(new[] { dat.waiter, dat1.waiter }, -1); | |
| // dat.WaitOne(); for one or "WaitHandle.WaitAny(new[] { dat.waiter, dat1.waiter }, -1);" for multible downloads | |
| Console.WriteLine("1: {0}%, {1} secs remaining", dat.percentage.ToString("0.0"), dat.eta.TotalSeconds); |
This file contains hidden or 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
| public static string md5(string input, hashFlag flag = 0) | |
| { | |
| StringBuilder sb = new StringBuilder(); | |
| Stream fs; | |
| if (flag == hashFlag.hashFile) | |
| if (File.Exists(input)) | |
| fs = File.OpenRead(input); | |
| else | |
| throw new Exception("File does not exist"); | |
| else |
This file contains hidden or 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
| public static Dictionary<U,T> dictConvert<U,T>(Dictionary<U,object> input) | |
| { | |
| var outp = new Dictionary<U, T>(); | |
| foreach (var item in input.Keys) | |
| { | |
| if (input[item].GetType() != typeof(T)) | |
| continue; | |
| if (!outp.ContainsKey(item)) | |
| outp.Add(item, (T)input[item]); | |
| else |
This file contains hidden or 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
| using System; | |
| using System.Collections.Concurrent; | |
| using System.Linq; | |
| using System.Threading; | |
| namespace JFunctions.Async | |
| { | |
| public class ThreadQueue | |
| { | |
| private ConcurrentQueue<Action> processQueue = new ConcurrentQueue<Action>(); |
This file contains hidden or 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
| private static void PatchHosts() | |
| { | |
| string HostFileLocation = @"C:\Windows\System32\drivers\etc\hosts"; | |
| Regex rgxHosts = new Regex(@"\b((\d{1,3}\.){3}\d{1,3})\b[ ]+([a-zA-Z0-9.]+)", RegexOptions.ECMAScript | RegexOptions.Compiled); | |
| List<String> HostsFile = new List<string>(File.ReadAllLines(HostFileLocation)); | |
| //Parse Entities into an easy <domain,ip> list | |
| var myDict = HostsFile | |
| .Select(m => m.Split("#")[0]).Where(m => m != "") | |
| .Select(m => rgxHosts.Match(m)) |
This file contains hidden or 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
| public class Byte | |
| { | |
| /// <summary> | |
| /// Gets the starting pointers in array of the given element | |
| /// </summary> | |
| /// <param name="array">Bigger element where is searched in</param> | |
| /// <param name="element">Tiny pattern which has to be matched in <see cref="array"/></param> | |
| /// <returns></returns> | |
| public static List<int> GetOccurancePtrs(byte[] array, byte[] element) | |
| { |
OlderNewer