Last active
July 24, 2019 06:33
-
-
Save langheran/961d321c06575d93fa122d9f942a9d35 to your computer and use it in GitHub Desktop.
Separate m3u into individual m3u.
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
| #SingleInstance, Force | |
| ; title:="Casós de Bet Din - Problemas de vecinos - Pe̝rdida de plusvali̝a - TuTorah TV - tutorah.tv" | |
| ; title:=RemoveLetterAccents(title) | |
| ; if(InStr(title,"plus")) | |
| ; msgbox, %title% | |
| ; return | |
| oFile:=FileOpen("Rabino Joshua Hilu.m3u","r") | |
| encoding:=oFile.Encoding | |
| ; MsgBox,4096,Debugging,Input file encoding=%encoding% ; shows that encoding is UTF-16 | |
| oFile.Close() | |
| count:=1 | |
| Loop | |
| { | |
| FileEncoding, UTF-8 | |
| FileReadLine, line, Rabino Joshua Hilu.m3u, %A_Index% | |
| if ErrorLevel | |
| break | |
| if(A_Index=1) | |
| header:=line | |
| else | |
| { | |
| if(Mod(count, 3)=1) | |
| { | |
| title:=RegexReplace(line,".*?,(.*)","$1") | |
| title:=RegexReplace(title,"\?","\?") | |
| title:=ToUTF8(title) | |
| title:=RemoveLetterAccents(title) | |
| title:=RegexReplace(title,"\\?","?") | |
| ; msgbox, % title | |
| ; if(InStr(title,"plus")) | |
| ; { | |
| ; Clipboard:=title | |
| ; msgbox, %title% | |
| ; } | |
| ; if(InStr(title,"caus")) | |
| ; msgbox, %title% | |
| } | |
| if(Mod(count, 3)=2) | |
| { | |
| conditions:=line | |
| } | |
| if(Mod(count, 3)=0) | |
| { | |
| url:=line | |
| path:=A_ScriptDir . "\" . title . ".m3u" | |
| FileRecycle, %path% | |
| FileAppend, %header%, %path% | |
| titleLine=#EXTINF:-1,%title% | |
| FileAppend, `n%titleLine%, %path% | |
| FileAppend, `n%conditions%, %path% | |
| FileAppend, `n%url%, %path% | |
| } | |
| count:=count+1 | |
| } | |
| } | |
| RemoveLetterAccents(text) | |
| { | |
| Arr:=["┴","ß","╔","Θ","═","φ","╙","≤","┌","·","e?","i?"] | |
| with=AaEeIiOoUuei | |
| For k, v In Arr | |
| { | |
| w:=SubStr(with,a_index,1) | |
| ; msgbox, %w% %v% | |
| text:=StrReplace(text,v,w) | |
| } | |
| return text | |
| } | |
| ToUTF8(ByRef String, ByRef Size := 0) { | |
| VarSetCapacity(var,1) | |
| VarSetCapacity(result,1) | |
| StrPut(String, &var, "cp0") ; to get an ansi coded var | |
| StrPut(StrGet(&var, "cp0"), &result, "UTF-8") ; copies it to result | |
| return StrGet(&result, "UTF-8") | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment