-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTVMazeAPI_UDF_Requirements.au3
183 lines (166 loc) · 5.25 KB
/
TVMazeAPI_UDF_Requirements.au3
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#include-once
#include <Date.au3>
#include <GDIPlus.au3>
Func _Countdown($airtime, $countdownMin)
Local $countdown = "", $nocountdown = 0
Local $Years = Round(Int($countdownMin / 525600), 0)
Local $months = Round(Int($countdownMin / 43200), 0)
Local $days = Int($countdownMin / 1440)
Local $hours = Int($countdownMin / 60)
$hours = Mod($hours, 24)
Local $minutes = $countdownMin
$minutes = Mod($minutes, 60)
If $days = "" Then
If $hours = "" Then
If $minutes = "" Then
$nocountdown = 1
Else
EndIf
EndIf
EndIf
If $nocountdown = 0 Then
$countdown = $countdown & $days & "d : "
If $hours = "0" Then
$countdown = $countdown & "0" & "h : "
If $minutes = "0" Then
$countdown = $countdown & "0" & "m"
Else
$countdown = $countdown & $minutes & "m"
EndIf
Else
$countdown = $countdown & $hours & "h : "
If $minutes = "0" Then
$countdown = $countdown & "0" & "m"
Else
$countdown = $countdown & $minutes & "m"
EndIf
EndIf
Else
$countdown = $countdown & "-"
EndIf
If $days >= 2 Then
$countdown = Round(((($days * 24) + $hours) / 24), 0)
Return $countdown & " days"
EndIf
If Not ($days = "") Then
If $days < 0 Then
If $Years < 0 Then
If ($Years < -1) Then
Return StringReplace($Years, "-", "") & " years ago"
Else
Return StringReplace($Years, "-", "") & " year ago"
EndIf
Else
If $months < -2 Then
If $months < -11 Then
Return "1 year ago"
Else
Return StringReplace($months, "-", "") & " months ago"
EndIf
Else
$countdown = StringReplace($days, "-", "")
If ($countdown > 1) Then
Return $countdown & " days ago"
Else
Return $countdown & " day ago"
EndIf
EndIf
EndIf
EndIf
EndIf
If StringInStr($countdown, "0d : 0h : -") Then Return "recently"
If StringInStr($countdown, "0d : 0h : 0m") Then Return "recently"
If StringInStr($countdown, "0d : -") Then Return "recently"
If ($Years = 0) And ($days = 0) And ($months = 0) And ($hours = 0) And ($minutes > 0) Then
Return $minutes&" minutes"
EndIf
If StringInStr($countdown, "0d :") And ($hours > 0) Then
Return $hours&"h"&" : "&$minutes&"m"
EndIf
Return $countdown
EndFunc ;==>_Countdown
Func _TimeZoneConversion($DateTime, $ConversionCode, $UserUTC, $DSTOption)
If StringInStr($ConversionCode, "-") Then
$ConversionCode = StringReplace($ConversionCode, "-", "+")
Else
$ConversionCode = StringReplace($ConversionCode, "+", "-")
EndIf
$ConversionCode = $ConversionCode + $UserUTC + $DSTOption
Return (_DateAdd('n', $ConversionCode, $DateTime))
EndFunc ;==>_TimeZoneConversion
Func _GetWeekday($Date, $Short = 1)
$Date = StringSplit($Date, "/", 2)
If $Short = 1 Then
Return _DateDayOfWeek(_DateToDayOfWeek($Date[0], $Date[1], StringLeft($Date[2], 2)), 1)
Else
Return _DateDayOfWeek(_DateToDayOfWeek($Date[0], $Date[1], StringLeft($Date[2], 2)), 0)
EndIf
EndFunc ;==>_GetWeekday
Func _HTML_StripTags($sHTMLData)
If $sHTMLData = "" Then Return SetError(1, 0, $sHTMLData)
Local $oHTML = ObjCreate("HTMLFILE")
If @error Then Return SetError(1, 0, $sHTMLData)
$oHTML.Open()
$oHTML.Write($sHTMLData)
Return SetError(0, 0, $oHTML.Body.innerText)
EndFunc ;==>_HTML_StripTags
Func _URIEncode($urlText)
$url = ""
For $i = 1 To StringLen($urlText)
$acode = Asc(StringMid($urlText, $i, 1))
Select
Case ($acode >= 48 And $acode <= 57) Or _
($acode >= 65 And $acode <= 90) Or _
($acode >= 97 And $acode <= 122)
$url = $url & StringMid($urlText, $i, 1)
Case $acode = 32
$url = $url & "+"
Case Else
$url = $url & "%" & Hex($acode, 2)
EndSelect
Next
Return $url
EndFunc ;==>_URIEncode
Func _INetGet($sURL, $fString = True)
Local $sString = InetRead($sURL, 1)
Local $iError = @error, $iExtended = @extended
If $fString = Default Or $fString Then $sString = BinaryToString($sString)
Return SetError($iError, $iExtended, _ANSI2UNICODE($sString))
EndFunc ;==>_INetGet
Func _Between($sString, $sStart, $sEnd)
Local $sCase = "(?is)"
$sStart = $sStart ? "\Q" & $sStart & "\E" : "\A"
$sEnd = $sEnd ? "(?=\Q" & $sEnd & "\E)" : "\z"
Local $aReturn = StringRegExp($sString, $sCase & $sStart & "(.*?)" & $sEnd, 3)
If @error Then Return SetError(1, 0, 0)
Return $aReturn
EndFunc ;==>_Between
Func ArrayDelete(ByRef $avArray, $iElement)
If Not IsArray($avArray) Then Return SetError(1, 0, 0)
Local $iUBound = UBound($avArray, 1) - 1
If $iElement < 0 Then $iElement = 0
If $iElement > $iUBound Then $iElement = $iUBound
Switch UBound($avArray, 0)
Case 1
For $i = $iElement To $iUBound - 1
$avArray[$i] = $avArray[$i + 1]
Next
ReDim $avArray[$iUBound]
Case 2
Local $iSubMax = UBound($avArray, 2) - 1
For $i = $iElement To $iUBound - 1
For $j = 0 To $iSubMax
$avArray[$i][$j] = $avArray[$i + 1][$j]
Next
Next
ReDim $avArray[$iUBound][$iSubMax + 1]
Case Else
Return SetError(3, 0, 0)
EndSwitch
Return $iUBound
EndFunc ;==>ArrayDelete
Func _ANSI2UNICODE($sString = "")
Local Const $SF_ANSI = 1
Local Const $SF_UTF8 = 4
Return BinaryToString(StringToBinary($sString, $SF_ANSI), $SF_UTF8)
EndFunc ;==>_ANSI2UNICODE