BinaryWorks.it Official Forum
BinaryWorks.it Official Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 eXtreme Movie Manager (Rel. 7), No More Updates
 Scripts
 OFDB-Script: Work-around for unicode special chars
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Oliver678
New Member

Germany
57 Posts

Posted - 16 Nov 2006 :  09:38:36  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic


Hi

Importing movies where the title contains special chars (i.e. german umlauts) is currently not possible with the MagicScript engine (which is used by XMM).
When querying for a movie title like "Bärenbrüder", MagicScript (based on .NET) converts the german umlauts to unicode characters. However querys with unicode characters are not yet supported by www.ofdb.de . Some websites seem to have support for unicode characters, i.e. www.wikipedia.org.

Luckily when querying www.ofdb.de with german umlauts (converted to unicode by MagicScript engine), www.ofdb.de responses with a web page containing (!) the search term (with unicoded german umlauts).
This search term can be parsed and "translated" by the script and re-used for a second query (without unicode characters but with characters which www.ofdb.de understands).

I already implemented this kind of parsing into the OFDB.de script. For me it works.

In my opinion it's really worth it to let the MagicScript engine do this translation stuff on its own.
But this work-around gives Alessio some additional weeks time to think about how to do it with .NET ;-)

Below is the new code. Sorry for the german comments. When I have some spare time I will translate the comments into english.

Alessio will probably upload the updated script as soon as he is able to.



[...]
#CREATEMOVIELIST#
    ------- Umlaute Start ---------------
    - MagicScript bietet keine Möglichkeit, eine Variable nachträglich zu parsen und ggf.
    - zu ändern. Es gibt aber über z.B. ofdb.txt zum Glück die Möglichkeit, den Suchbegriff
    - im HTML-Code der Webseite zu parsen und ggf. zu ändern.
    - Bei ofdb.txt muß z.B. nach folgender Zeile gesucht werden:
    -           Suchbegriff(e): <font color="#005500"> Bärenbrüder </font><br><br><br>

    #STARTREADWEB#
    #FINDLINE#=Suchbegriff(e):#12##ONERROR#=*STOP*
    - Variable #01# : Zählt absolute Spaltenposition mit
    #FIND#=>#01##ONERROR#=*STOP*

    - Nach dem Suchbegriff (Titel) folgt ein Leerzeichen und dann
    - das Stop-Zeichen "<"
    #PUT#=<#08#

    - In der Variable 09 wird der Status gespeichert, ob im Titel Umlaute bzw.
    - Unicode-Characters gefunden wurden. 0=nein, 1=ja
    #PUT#=0#09#
    - Damit später festgestellt werden kann, ob Unicodes gefunden wurden,
    - müssen wir noch in der Variable 13 festhalten, daß dies der Fall ist,
    - wenn die Variable 09 den Wert 1 enthält.
    #PUT#=1#13#

    - Ein Unicode-Character besteht aus zwei Bytes.
    - Hier wird das erste der beiden Bytes definiert.    
    #PUT#=Ã#90#
    - ä,ö,ü,Ä,Ö,Ü,ß
    #PUT#=¤#91#
    #PUT#=¶#92#
    #PUT#=¼#93#
    #PUT#=„#94#
    #PUT#=-#95#
    #PUT#=œ#96#
    #PUT#=Ÿ#97#

    - Der Befehl TAKEWORDLEN akzeptiert nur Variablen, deshalb müssen
    - wir vorher Variablen mit entsprechenden Byte-Anzahl-Varianten
    - vorbereiten. Wir brauchen entweder ein Byte (ASCII) oder zwei Bytes (Unicode)
    #PUT#=1#11#
    #PUT#=2#12#

    - Der bereinigte Titel wird in der Variablen 04 zusammengesetzt.
    #PUT#=#04#

    - Jetzt kann das Parsen und ggf. Übersetzen des Titels beginnen
    #REPEAT#

      #PUTCURSOR#=#01#

      - Ab der aktuellen Cursorposition ein Byte auslesen (Anzahl von 1
      - steht in Variable 11) und in 03 speichern.
      #TAKEWORDLEN#=#03#,#01#,#11#

      - Sollte das Stop-Zeichen hinter dem Suchbegriff erreicht werden,
      - kann die Schleife via GOTO verlassen werden.
      #IF# #03#==#08#
        #GOTO# FOUNDENDOFTITLE
      #ENDIF#

      - Sollte ein Unicode-Character gefunden werden, muss noch
      - ein zweites Byte ausgelesen werden.
      #IF# #03#==#90#

        #COMPUTECURSOR#=+1
        #PUTCURSOR#=#01#
        #TAKEWORDLEN#=#03#,#01#,#11#

        - Unicode-Character wurde gefunden. Das müssen wir uns merken.
        #PUT#=1#09#
      #ENDIF#      

      - In der Variablen 05 wird das bereinigte/übersetzte Byte (Zeichen)
      - gespeichert. Entweder bekommt sie das ursprüngliche Zeichen oder
      - das übersetzte.
      #STRING#=#05#=#03#
      #IF# #03#==#91#
        #STRING#=#05#=%E4
      #ENDIF#
      #IF# #03#==#92#
        #STRING#=#05#=%F6
      #ENDIF#
      #IF# #03#==#93#
        #STRING#=#05#=%FC
      #ENDIF#
      #IF# #03#==#94#
        #STRING#=#05#=%C4
      #ENDIF#
      #IF# #03#==#95#
        #STRING#=#05#=%D6
      #ENDIF#
      #IF# #03#==#96#
        #STRING#=#05#=%DC
      #ENDIF#
      #IF# #03#==#97#
        #STRING#=#05#=%DF
      #ENDIF#

      - In der Variablen 04 wird der Suchbegriff übersetzt zusammengesetzt.
      #STRING#=#04#=#04##05#

      - Spaltenposition muß in der Variablen 01 und beim Cursor schon
      - beim ersten Durchlauf um den Wert 1 erhöht werden. Bei ofdb.txt
      - gibt's nach dem Stop-Zeichen ">" noch ein Leerzeichen " ".
      #COMPUTECURSOR#=+1

      :FOUNDENDOFTITLE
      - Schleife läuft, solange wir nicht das Stop-Zeichen "<" erreicht
      - haben.
    #WHILE# #03#<>#08#

    #CHECKVARIABLE#=#04#
    #TRIM#


    - Nur wenn Unicodes gefunden bzw. ersetzt wurden, muß erneut
    - auf ofdb.de nach dem (übersetzten) Titel gesucht werden.
    #IF# #09#==#13#
      #STRING#=#03#=http://www.ofdb.de/view.php?page=suchergebnis&Kat=Titel&SText=#04#
      #OPENNEWWEB#=#03#
    #ENDIF#

    ------- Umlaute Ende ---------------


    #STARTREADWEB#
    #PUT#=1#21#

    [...]




Oliver

Alessio Viti
Forum Admin

Italy
9171 Posts

Posted - 16 Nov 2006 :  13:24:03  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you Oliver!

The script is up, just use the liveupdate to take it.

Alessio
Go to Top of Page

Piano
Starting Member

Germany
45 Posts

Posted - 16 Nov 2006 :  21:42:38  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply

... and it workx !

thanks.

Piano
Go to Top of Page

carsten
Starting Member

44 Posts

Posted - 18 Jan 2007 :  23:15:52  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I still have problems with german umlauts:
Tornado - Tödlicher Sog is not found.
Tornado - Todlicher Sog is found.
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
BinaryWorks.it Official Forum © Binaryworks.it Go To Top Of Page
Generated in 0.14 sec. Powered By: Snitz Forums 2000 Version 3.4.07