Guest User

Metz Senderliste

a guest
May 26th, 2014
474
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. set thefile to choose file
  3. set endOfFile to get eof of thefile
  4. set fileContent to read thefile
  5.  
  6. set fileVersion to (text 1 thru 2 of fileContent)
  7. --log fileVersion
  8. --log (id of fileVersion)
  9. if fileVersion ≠ character id 0 & character id 4 then
  10.     display dialog "Sorry, unbekanntes Dateiformat. Es wird nur das 4er mit der Dateiendung '.mst40' unterstützt"
  11.     return -128
  12. else
  13.     --log ("Treffer")
  14.     -- weiter gehts
  15. end if
  16.  
  17.  
  18. set newDelims to character id 0 & character id 0 & character id 0 & character id 0 & character id 4 --& character id 5
  19. set AppleScript's text item delimiters to newDelims
  20.  
  21. log ("--------------")
  22. set channelList to text items of fileContent
  23. set senderCountAll to (count channelList)
  24. --log (senderCountAll)
  25. set AppleScript's text item delimiters to ""
  26.  
  27.  
  28.  
  29. on getAllgemein(aChannel)
  30.     set aLen to 0
  31.     set aName to ""
  32.     set aDecoder to false
  33.     set aKlang to 0
  34.     set aKlangKorr to 0
  35.     set aEPG to false
  36.    
  37.     -- Länge des Namens
  38.     set aLen to id of (character 2 of aChannel)
  39.    
  40.     -- Name
  41.     set aName to text 3 thru (3 + aLen - 1) of aChannel
  42.     --log {aLen, aName}
  43.    
  44.     -- charCodeTable
  45.     set aCharCodeTable to id of (character (aLen + 3) of aChannel)
  46.    
  47.     -- Decoder (yes/no) {0=off, 1 = on}
  48.     if (id of (character (aLen + 4) of aChannel)) = 1 then set aDecoder to true
  49.    
  50.     -- Klangeinstellung (generell / Sprache / Normal){ 0,1,2}
  51.     set aKlang to id of (character (aLen + 5) of aChannel)
  52.    
  53.     -- Lautstärkeeinstellung (-30..30)
  54.     set aKlangKorr to id of (character (aLen + 6) of aChannel)
  55.     if aKlangKorr > 29 then set aKlangKorr to -256 + aKlangKorr
  56.    
  57.     -- in EPG anzeigen (true / false) {0=off, 1 = on}
  58.     if (id of (character (aLen + 7) of aChannel)) = 1 then set aEPG to true
  59.    
  60.    
  61.     return {aLen + 7, aName, aCharCodeTable, aDecoder, aKlang, aKlangKorr, aEPG}
  62. end getAllgemein
  63.  
  64.  
  65. on getTV(aChannel, someOffset)
  66.     set aCNI to 0
  67.     set aColKorr to 0
  68.     set aKontKorr to 0
  69.     set aRausch to 0
  70.     set aRauschKorr to 0
  71.     set aCTI to 0
  72.    
  73.     -- CNI-Daten ($0000)
  74.     log (id of text (someOffset + 1) thru (someOffset + 8) of aChannel)
  75.     -- wer bekommt das Byte dazwischen???
  76.    
  77.     set {a, b} to {id of (character (someOffset + 2) of aChannel), id of (character (someOffset + 1) of aChannel)}
  78.     set aCNI to do shell script "perl -e 'printf(\"%02X%02X\", " & "18, 52" & ")'" --> "1234"
  79.     -- http://macscripter.net/viewtopic.php?pid=71021
  80.    
  81.     -- Farbstärke-Korr (-30..30)
  82.     set aFarbKorr to id of (character (someOffset + 4) of aChannel)
  83.     if aFarbKorr > 29 then set aFarbKorr to -256 + aKlangKorr
  84.    
  85.     -- Kontrast-Korr (-30..30)
  86.     set aKontKorr to id of (character (someOffset + 5) of aChannel)
  87.     if aKontKorr > 29 then set aKontKorr to -256 + aKlangKorr
  88.    
  89.     -- Bildschärfe-Korr (generell / 0..5) = = generell?
  90.     set aBildKorr to id of (character (someOffset + 6) of aChannel)
  91.    
  92.     -- Rauschred. (0..5)
  93.     set aRauschRed to id of (character (someOffset + 7) of aChannel)
  94.    
  95.     -- CTI (generell / aus / ein)
  96.     set aCTI to id of (character (someOffset + 8) of aChannel)
  97.    
  98.     -- Kammfilter (generell / aus / ein)
  99.     set aKammfilter to id of (character (someOffset + 9) of aChannel)
  100.    
  101.     -- Farbversatz (-3..3)
  102.     set aFarbversatz to id of (character (someOffset + 10) of aChannel)
  103.     if aFarbversatz > 3 then set aFarbversatz to -256 + aFarbversatz
  104.    
  105.     -- Bildformat (4:3 / 16:9 / auto / original)
  106.     set aBildformat to id of (character (someOffset + 11) of aChannel)
  107.    
  108.     -- Videoprofil (Sport / Brillant / Spiele / PC-Monitor / Benutzer / undef.) {0..7}
  109.     set aVideoprofil to id of (character (someOffset + 12) of aChannel)
  110.    
  111.     return {someOffset + 12, aCNI, aFarbKorr, aKontKorr, aBildKorr, aRauschRed, aCTI, aKammfilter, aFarbversatz, aBildformat, aVideoprofil}
  112. end getTV
  113.  
  114.  
  115. on getsystemIDs(aSender, someOffset)
  116.     return {}
  117. end getsystemIDs
  118.  
  119. on getPID(aSender, someOffset)
  120.     return {}
  121. end getPID
  122.  
  123. on getDVB(aChannel, someOffset)
  124.     set aCNI to 0
  125.     set aColKorr to 0
  126.     set aKontKorr to 0
  127.     set aRausch to 0
  128.     set aRauschKorr to 0
  129.     set aCTI to 0
  130.    
  131.    
  132.     -- serviceID
  133.     -- verschl.
  134.     -- CA-Nr
  135.     -- Video-Dec
  136.     -- Sub-Audio
  137.     -- Audio-Tag
  138.     -- Videoformat
  139.     -- Audioformat
  140.    
  141.     -- CA-System-IDs ( 0..15 2x hex als {})
  142.     repeat with i from 1 to 16
  143.         set aCaSystemIDs to aCaSystemIDs & {getsystemIDs(aSender, someOffset)} -- offset wohl *2
  144.     end repeat
  145.    
  146.    
  147.     -- PCR-PID / Teletext-PID / Audio-PID /Video-PID
  148.     set aPIDs to {getPID(aSender, someOffset), getPID(aSender, someOffset), getPID(aSender, someOffset), getPID(aSender, someOffset)}
  149.    
  150.    
  151.     return {someOffset + xx, aCNI, aFarbKorr, aKontKorr, aBildKorr, aRauschRed, aCTI, aKammfilter, aFarbversatz, aBildformat, aVideoprofil}
  152. end getDVB
  153.  
  154.  
  155.  
  156. -- TV Sender (kommen wohl immer zuerst)
  157. set tvSenderCountFromFile to id of character 3 of fileContent
  158. set tvChannelList to items 2 thru (tvSenderCountFromFile + 1) of channelList
  159.  
  160.  
  161. set senderID to 0
  162. log ("Senderliste TV, Anz: " & tvSenderCountFromFile)
  163. log ("===============")
  164. repeat with i from 1 to count tvChannelList
  165.     set isTV to false
  166.    
  167.     set aSender to item i of tvChannelList
  168.     --  log aSender
  169.     set senderLen to length of aSender
  170.     --log length of aSender
  171.    
  172.     set dataType to id of (character 1 of aSender)
  173.     --log {dataType, class of dataType}
  174.    
  175.     (*
  176.     dataType =
  177.     0 = unused
  178.     1 = Analog  OK
  179.     2 = DVB-S
  180.     3 = DVB-S2
  181.     4 = DVB-T
  182.     5 = DVB-C   OK
  183.     *)
  184.     if dataType = 1 then
  185.         set isTV to true
  186.         set tvIn to "Analog"
  187.     end if
  188.    
  189.     if dataType = 5 then
  190.         set isTV to true
  191.         set tvIn to "DVB-T "
  192.     end if
  193.    
  194.    
  195.     if isTV then
  196.         set senderID to senderID + 1
  197.         set dataType to "TV"
  198.        
  199.         (* allgemein *)
  200.         set {nameOff, channelName, charCodeTable, decoder, klang, lautKorr, inEPG} to getAllgemein(aSender)
  201.         log {"allgemein", nameOff, dataType, senderID, senderLen, channelName, charCodeTable, decoder, klang, lautKorr, inEPG}
  202.        
  203.        
  204.         (* TV-Programmplatzdaten *)
  205.         set {nameOff, cni, farbKorr, kontkorr, bildKorr, rauschRed, cti, kammfilter, farbversatz, bildformat, videoprofil} to getTV(aSender, nameOff + 1)
  206.         log {"TV-Programmplatzdaten", cni, farbKorr, kontkorr, bildKorr, rauschRed, cti, kammfilter, farbversatz, bildformat, videoprofil}
  207.        
  208.        
  209.         (* Terrestische Programmplatzdaten (ANALOG)*)
  210.         if dataType = 1 then
  211.             -- Freq.
  212.             -- VCR (aus / Opt.1 / Opt.2)
  213.             -- Zwangsmono (ein / aus)
  214.             -- Farbnorm (Automatik / PAL / SECAM / NTSC / NTSC44 / PAL60 / PAL M / PAL N)
  215.             -- TV-Standard (B/G, D/K, I, L M/N)
  216.         end if
  217.        
  218.        
  219.         (* DVB*)
  220.         if {3, 4, 5} contains dataType then
  221.             set {nameOff, serviceID, locked, caNr, videoDecoder, subAudio, audioTag, videoFormat, audioFormat, casystemPIDs, pIDs} to getDVB(aSender, nameOff + 1)
  222.             log {"DVB", nameOff, serviceID, locked, caNr, videoDecoder, subAudio, audioTag, videoFormat, audioFormat, casystemPIDs, pIDs}
  223.         end if
  224.        
  225.        
  226.         (* Knoten allgm.*)
  227.         -- Netzwerk-Typ
  228.         --Transport-Stream-ID
  229.         -- Original-Network-ID
  230.         -- Freq
  231.         --Symbolrate
  232.        
  233.        
  234.         (* Knoten DVB-C*)
  235.         -- Modulation (xxx)
  236.        
  237.        
  238.     else
  239.         log ("was soll der Typ hier sein?")
  240.     end if
  241.    
  242.    
  243.     log ("-------------------------------------------------")
  244. end repeat
  245. log
  246. log
  247.  
  248.  
  249. -- Radiosender
  250. set lastTvChannel to last item of tvChannelList
  251. set radioSenderCountFromFile to ASCII number of last character of lastTvChannel
  252. log radioSenderCountFromFile
  253.  
  254. set radioChannelList to items (tvSenderCountFromFile + 2) thru (tvSenderCountFromFile + radioSenderCountFromFile * 2) of channelList
  255.  
  256. set senderID to 0
  257. log ("Senderliste Radio, Anz: " & radioSenderCountFromFile)
  258. log ("===================")
  259. repeat with i from 1 to count radioChannelList by 2
  260.     --log i
  261.     set isRadio to false
  262.     set aSender to item i of radioChannelList
  263.     --log aSender
  264.    
  265.     set senderLen to length of aSender
  266.     --log length of aSender
  267.    
  268.     set dataType to id of (character 1 of aSender)
  269.     --log {dataType, class of dataType}
  270.    
  271.    
  272.     if dataType = 10 then set isRadio to true
  273.    
  274.     if isRadio then
  275.         set senderID to senderID + 1
  276.         set dataType to "Radio"
  277.        
  278.         (* allgemein *)
  279.         set {channelName, charCodeTable, decoder, klang, lautKorr, inEPG} to getAllgemein(aSender)
  280.         log {"allgemein", dataType, senderID, senderLen, channelName, charCodeTable, decoder, klang, lautKorr, inEPG}
  281.        
  282.         --log ("--------------")
  283.     else
  284.         log {dataType, "was soll der Typ hier sein?"}
  285.     end if
  286.    
  287. end repeat
Advertisement
Add Comment
Please, Sign In to add comment