Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set thefile to choose file
- set endOfFile to get eof of thefile
- set fileContent to read thefile
- set fileVersion to (text 1 thru 2 of fileContent)
- --log fileVersion
- --log (id of fileVersion)
- if fileVersion ≠ character id 0 & character id 4 then
- display dialog "Sorry, unbekanntes Dateiformat. Es wird nur das 4er mit der Dateiendung '.mst40' unterstützt"
- return -128
- else
- --log ("Treffer")
- -- weiter gehts
- end if
- set newDelims to character id 0 & character id 0 & character id 0 & character id 0 & character id 4 --& character id 5
- set AppleScript's text item delimiters to newDelims
- log ("--------------")
- set channelList to text items of fileContent
- set senderCountAll to (count channelList)
- --log (senderCountAll)
- set AppleScript's text item delimiters to ""
- on getAllgemein(aChannel)
- set aLen to 0
- set aName to ""
- set aDecoder to false
- set aKlang to 0
- set aKlangKorr to 0
- set aEPG to false
- -- Länge des Namens
- set aLen to id of (character 2 of aChannel)
- -- Name
- set aName to text 3 thru (3 + aLen - 1) of aChannel
- --log {aLen, aName}
- -- charCodeTable
- set aCharCodeTable to id of (character (aLen + 3) of aChannel)
- -- Decoder (yes/no) {0=off, 1 = on}
- if (id of (character (aLen + 4) of aChannel)) = 1 then set aDecoder to true
- -- Klangeinstellung (generell / Sprache / Normal){ 0,1,2}
- set aKlang to id of (character (aLen + 5) of aChannel)
- -- Lautstärkeeinstellung (-30..30)
- set aKlangKorr to id of (character (aLen + 6) of aChannel)
- if aKlangKorr > 29 then set aKlangKorr to -256 + aKlangKorr
- -- in EPG anzeigen (true / false) {0=off, 1 = on}
- if (id of (character (aLen + 7) of aChannel)) = 1 then set aEPG to true
- return {aLen + 7, aName, aCharCodeTable, aDecoder, aKlang, aKlangKorr, aEPG}
- end getAllgemein
- on getTV(aChannel, someOffset)
- set aCNI to 0
- set aColKorr to 0
- set aKontKorr to 0
- set aRausch to 0
- set aRauschKorr to 0
- set aCTI to 0
- -- CNI-Daten ($0000)
- log (id of text (someOffset + 1) thru (someOffset + 8) of aChannel)
- -- wer bekommt das Byte dazwischen???
- set {a, b} to {id of (character (someOffset + 2) of aChannel), id of (character (someOffset + 1) of aChannel)}
- set aCNI to do shell script "perl -e 'printf(\"%02X%02X\", " & "18, 52" & ")'" --> "1234"
- -- http://macscripter.net/viewtopic.php?pid=71021
- -- Farbstärke-Korr (-30..30)
- set aFarbKorr to id of (character (someOffset + 4) of aChannel)
- if aFarbKorr > 29 then set aFarbKorr to -256 + aKlangKorr
- -- Kontrast-Korr (-30..30)
- set aKontKorr to id of (character (someOffset + 5) of aChannel)
- if aKontKorr > 29 then set aKontKorr to -256 + aKlangKorr
- -- Bildschärfe-Korr (generell / 0..5) = = generell?
- set aBildKorr to id of (character (someOffset + 6) of aChannel)
- -- Rauschred. (0..5)
- set aRauschRed to id of (character (someOffset + 7) of aChannel)
- -- CTI (generell / aus / ein)
- set aCTI to id of (character (someOffset + 8) of aChannel)
- -- Kammfilter (generell / aus / ein)
- set aKammfilter to id of (character (someOffset + 9) of aChannel)
- -- Farbversatz (-3..3)
- set aFarbversatz to id of (character (someOffset + 10) of aChannel)
- if aFarbversatz > 3 then set aFarbversatz to -256 + aFarbversatz
- -- Bildformat (4:3 / 16:9 / auto / original)
- set aBildformat to id of (character (someOffset + 11) of aChannel)
- -- Videoprofil (Sport / Brillant / Spiele / PC-Monitor / Benutzer / undef.) {0..7}
- set aVideoprofil to id of (character (someOffset + 12) of aChannel)
- return {someOffset + 12, aCNI, aFarbKorr, aKontKorr, aBildKorr, aRauschRed, aCTI, aKammfilter, aFarbversatz, aBildformat, aVideoprofil}
- end getTV
- on getsystemIDs(aSender, someOffset)
- return {}
- end getsystemIDs
- on getPID(aSender, someOffset)
- return {}
- end getPID
- on getDVB(aChannel, someOffset)
- set aCNI to 0
- set aColKorr to 0
- set aKontKorr to 0
- set aRausch to 0
- set aRauschKorr to 0
- set aCTI to 0
- -- serviceID
- -- verschl.
- -- CA-Nr
- -- Video-Dec
- -- Sub-Audio
- -- Audio-Tag
- -- Videoformat
- -- Audioformat
- -- CA-System-IDs ( 0..15 2x hex als {})
- repeat with i from 1 to 16
- set aCaSystemIDs to aCaSystemIDs & {getsystemIDs(aSender, someOffset)} -- offset wohl *2
- end repeat
- -- PCR-PID / Teletext-PID / Audio-PID /Video-PID
- set aPIDs to {getPID(aSender, someOffset), getPID(aSender, someOffset), getPID(aSender, someOffset), getPID(aSender, someOffset)}
- return {someOffset + xx, aCNI, aFarbKorr, aKontKorr, aBildKorr, aRauschRed, aCTI, aKammfilter, aFarbversatz, aBildformat, aVideoprofil}
- end getDVB
- -- TV Sender (kommen wohl immer zuerst)
- set tvSenderCountFromFile to id of character 3 of fileContent
- set tvChannelList to items 2 thru (tvSenderCountFromFile + 1) of channelList
- set senderID to 0
- log ("Senderliste TV, Anz: " & tvSenderCountFromFile)
- log ("===============")
- repeat with i from 1 to count tvChannelList
- set isTV to false
- set aSender to item i of tvChannelList
- -- log aSender
- set senderLen to length of aSender
- --log length of aSender
- set dataType to id of (character 1 of aSender)
- --log {dataType, class of dataType}
- (*
- dataType =
- 0 = unused
- 1 = Analog OK
- 2 = DVB-S
- 3 = DVB-S2
- 4 = DVB-T
- 5 = DVB-C OK
- *)
- if dataType = 1 then
- set isTV to true
- set tvIn to "Analog"
- end if
- if dataType = 5 then
- set isTV to true
- set tvIn to "DVB-T "
- end if
- if isTV then
- set senderID to senderID + 1
- set dataType to "TV"
- (* allgemein *)
- set {nameOff, channelName, charCodeTable, decoder, klang, lautKorr, inEPG} to getAllgemein(aSender)
- log {"allgemein", nameOff, dataType, senderID, senderLen, channelName, charCodeTable, decoder, klang, lautKorr, inEPG}
- (* TV-Programmplatzdaten *)
- set {nameOff, cni, farbKorr, kontkorr, bildKorr, rauschRed, cti, kammfilter, farbversatz, bildformat, videoprofil} to getTV(aSender, nameOff + 1)
- log {"TV-Programmplatzdaten", cni, farbKorr, kontkorr, bildKorr, rauschRed, cti, kammfilter, farbversatz, bildformat, videoprofil}
- (* Terrestische Programmplatzdaten (ANALOG)*)
- if dataType = 1 then
- -- Freq.
- -- VCR (aus / Opt.1 / Opt.2)
- -- Zwangsmono (ein / aus)
- -- Farbnorm (Automatik / PAL / SECAM / NTSC / NTSC44 / PAL60 / PAL M / PAL N)
- -- TV-Standard (B/G, D/K, I, L M/N)
- end if
- (* DVB*)
- if {3, 4, 5} contains dataType then
- set {nameOff, serviceID, locked, caNr, videoDecoder, subAudio, audioTag, videoFormat, audioFormat, casystemPIDs, pIDs} to getDVB(aSender, nameOff + 1)
- log {"DVB", nameOff, serviceID, locked, caNr, videoDecoder, subAudio, audioTag, videoFormat, audioFormat, casystemPIDs, pIDs}
- end if
- (* Knoten allgm.*)
- -- Netzwerk-Typ
- --Transport-Stream-ID
- -- Original-Network-ID
- -- Freq
- --Symbolrate
- (* Knoten DVB-C*)
- -- Modulation (xxx)
- else
- log ("was soll der Typ hier sein?")
- end if
- log ("-------------------------------------------------")
- end repeat
- log
- log
- -- Radiosender
- set lastTvChannel to last item of tvChannelList
- set radioSenderCountFromFile to ASCII number of last character of lastTvChannel
- log radioSenderCountFromFile
- set radioChannelList to items (tvSenderCountFromFile + 2) thru (tvSenderCountFromFile + radioSenderCountFromFile * 2) of channelList
- set senderID to 0
- log ("Senderliste Radio, Anz: " & radioSenderCountFromFile)
- log ("===================")
- repeat with i from 1 to count radioChannelList by 2
- --log i
- set isRadio to false
- set aSender to item i of radioChannelList
- --log aSender
- set senderLen to length of aSender
- --log length of aSender
- set dataType to id of (character 1 of aSender)
- --log {dataType, class of dataType}
- if dataType = 10 then set isRadio to true
- if isRadio then
- set senderID to senderID + 1
- set dataType to "Radio"
- (* allgemein *)
- set {channelName, charCodeTable, decoder, klang, lautKorr, inEPG} to getAllgemein(aSender)
- log {"allgemein", dataType, senderID, senderLen, channelName, charCodeTable, decoder, klang, lautKorr, inEPG}
- --log ("--------------")
- else
- log {dataType, "was soll der Typ hier sein?"}
- end if
- end repeat
Advertisement
Add Comment
Please, Sign In to add comment