-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathUtilities.cs
101 lines (93 loc) · 3.02 KB
/
Utilities.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Data.SqlClient;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
namespace iptvChannelChecker
{
static class Utilities
{
public static string RemoveIllegalFileNameChars(string input, string replacement = "-")
{
var regexSearch = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars());
var r = new Regex(string.Format("[{0}]", Regex.Escape(regexSearch)));
return r.Replace(input, replacement);
}
public static string ResolutionSuperScript(int width)
{
string resolutionLevelSuperScript;
if (width > 1280)
{
resolutionLevelSuperScript = "ᴴ";
}
else if (width > 1024)
{
resolutionLevelSuperScript = "ʰ";
}
else if (width > 640)
{
resolutionLevelSuperScript = "ˢ";
}
else if (width > 0)
{
resolutionLevelSuperScript = "ˣ";
}
else
{
resolutionLevelSuperScript = "";
}
return resolutionLevelSuperScript;
}
public static string FrameRateSuperScript(int frameRateInt)
{
string frameRateSuperScript;
switch (frameRateInt)
{
case 90:
frameRateSuperScript = "⁹⁰";
break;
case 60:
frameRateSuperScript = "⁶⁰";
break;
case 50:
frameRateSuperScript = "⁵⁰";
break;
case 30:
frameRateSuperScript = "³⁰";
break;
case 26:
frameRateSuperScript = "²⁶";
break;
case 25:
frameRateSuperScript = "²⁵";
break;
case 24:
frameRateSuperScript = "²⁴";
break;
default:
frameRateSuperScript = "⁰⁰";
break;
}
return frameRateSuperScript;
}
public static string ExtractData(string inputLine, string thingToGet)
{
int thingToGetLength = thingToGet.Length + 2;
int startIndex = 0;
int endIndex = 0;
int stringLength = 0;
if (inputLine.Contains(thingToGet))
{
startIndex = inputLine.IndexOf(thingToGet) + thingToGetLength;
endIndex = inputLine.IndexOf("\"", startIndex);
stringLength = endIndex - startIndex;
return inputLine.Substring(startIndex, stringLength);
}
return string.Empty;
}
}
}