Ankündigung

Einklappen
Keine Ankündigung bisher.

[mmh] CommandServer

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

    #16
    Hallo Sascha,

    hab versucht auf udp umzustellen und erhalte folgendes Ergebnis:

    19:53:33.628 - network: udp message from IP, size 64 bytes
    19:53:33.629 - parser: parsing sequence: <UDP.SOCK><SEND=SELECT c00 FROM movie WHERE c07=2006></UDP.SOCK>
    19:53:33.630 - parser: command: UDP.SOCK - SEND=SELECT c00 FROM movie WHERE c07=2006
    19:53:33.630 - parser: reply sequence: <UDP.SOCK>SEND=|OK</UDP.SOCK>
    19:53:33.633 - commandserver: UDP send: IP:8000 data: SELECT c00 FROM movie WHERE c07=2006
    19:53:33.638 - commandserver: UDP receive: IP:8000 data: |16 Blocks
    19:53:33.640 - commandserver: translated reply sequence: <UDP.SOCK>|16 Blocks|OK</UDP.SOCK>
    19:53:33.648 - network: message parsed
    19:53:33.666 - commandserver: UDP receive: IP:8000 data: |300
    19:53:33.670 - commandserver: translated reply sequence: <UDP.SOCK>|300|OK</UDP.SOCK>
    19:53:33.688 - commandserver: UDP receive: IP:8000 data: |An Inconvenient Truth
    19:53:33.690 - commandserver: translated reply sequence: <UDP.SOCK>|An Inconvenient Truth|OK</UDP.SOCK>
    19:53:33.707 - commandserver: UDP receive: IP:8000 data: |Babel
    19:53:33.708 - commandserver: translated reply sequence: <UDP.SOCK>|Babel|OK</UDP.SOCK>
    19:53:33.726 - commandserver: UDP receive: IP:8000 data: |Blood Diamond
    19:53:33.727 - commandserver: translated reply sequence: <UDP.SOCK>|Blood Diamond|OK</UDP.SOCK>
    19:53:33.744 - commandserver: UDP receive: IP:8000 data: |Das Leben der Anderen
    19:53:33.746 - commandserver: translated reply sequence: <UDP.SOCK>|Das Leben der Anderen|OK</UDP.SOCK>
    19:53:33.763 - commandserver: UDP receive: IP:8000 data: |Deja Vu
    19:53:33.765 - commandserver: translated reply sequence: <UDP.SOCK>|Deja Vu|OK</UDP.SOCK>
    19:53:33.782 - commandserver: UDP receive: IP:8000 data: |Dreamgirls
    19:53:33.783 - commandserver: translated reply sequence: <UDP.SOCK>|Dreamgirls|OK</UDP.SOCK>
    19:53:33.800 - commandserver: UDP receive: IP:8000 data: |Pirates of the Caribbean: Dead Man's Chest
    19:53:33.802 - commandserver: translated reply sequence: <UDP.SOCK>|Pirates of the Caribbean: Dead Man's Chest|OK</UDP.SOCK>
    19:53:33.819 - commandserver: UDP receive: IP:8000 data: |Hollywoodland
    19:53:33.821 - commandserver: translated reply sequence: <UDP.SOCK>|Hollywoodland|OK</UDP.SOCK>
    19:53:33.838 - commandserver: UDP receive: IP:8000 data: |The Departed
    19:53:33.839 - commandserver: translated reply sequence: <UDP.SOCK>|The Departed|OK</UDP.SOCK>
    19:53:33.860 - commandserver: UDP receive: IP:8000 data: |The Good Shepherd
    19:53:33.862 - commandserver: translated reply sequence: <UDP.SOCK>|The Good Shepherd|OK</UDP.SOCK>
    19:53:33.880 - commandserver: UDP receive: IP:8000 data: |The Prestige
    19:53:33.882 - commandserver: translated reply sequence: <UDP.SOCK>|The Prestige|OK</UDP.SOCK>
    19:53:33.900 - commandserver: UDP receive: IP:8000 data: |Volver
    19:53:33.901 - commandserver: translated reply sequence: <UDP.SOCK>|Volver|OK</UDP.SOCK>
    19:53:33.918 - commandserver: UDP receive: IP:8000 data: |Cars
    19:53:33.920 - commandserver: translated reply sequence: <UDP.SOCK>|Cars|OK</UDP.SOCK>
    19:53:33.937 - commandserver: UDP receive: IP:8000 data: |The Da Vinci Code
    19:53:33.939 - commandserver: translated reply sequence: <UDP.SOCK>|The Da Vinci Code|OK</UDP.SOCK>
    19:53:33.956 - commandserver: UDP receive: IP:8000 data: |Penelope
    19:53:33.958 - commandserver: translated reply sequence: <UDP.SOCK>|Penelope|OK</UDP.SOCK>
    19:53:33.975 - commandserver: UDP receive: IP:8000 data: |Rescue Dawn
    19:53:33.976 - commandserver: translated reply sequence: <UDP.SOCK>|Rescue Dawn|OK</UDP.SOCK>
    19:53:33.994 - commandserver: UDP receive: IP:8000 data: |Notebook
    19:53:33.995 - commandserver: translated reply sequence: <UDP.SOCK>|Notebook|OK</UDP.SOCK>
    19:53:34.012 - commandserver: UDP receive: IP:8000 data: |Trixie
    19:53:34.015 - commandserver: translated reply sequence: <UDP.SOCK>|Trixie|OK</UDP.SOCK>

    Jetzt kommt jeder Titel einzeln.

    Im Terminal sieht das Ergebnis der Sqlite Abfrage so aus:
    |16 Blocks|300|An Inconvenient Truth|Babel|Blood Diamond|Das Leben der Anderen|Deja Vu|Dreamgirls|Pirates of the Caribbean: Dead Man's Chest|Hollywoodland|The Departed|The Good Shepherd|The Prestige|Volver|Cars|The Da Vinci Code|Penelope|Rescue Dawn|Notebook|Trixie

    Das Perl Script für den Server:

    # UDP message server
    use strict;
    use DBI;
    use IO::Socket;
    use Encode qw(decode);

    # Datenbank
    my $dbargs = {AutoCommit => 0, PrintError => 1};
    my $dbh = DBI->connect("dbi:SQLite:dbname=MyVideos34.db", "", "", $dbargs);

    my($data, $sock, $res, $newmsg, $MAXLEN, $PORTNO);

    $MAXLEN = 1024;
    $PORTNO = 8000;

    $sock = IO::Socket::INET->new(LocalPort => $PORTNO, Proto => 'udp')
    or die "socket: $@";
    print "Warte auf UDP Nachricht von Port $PORTNO\n";
    while ($sock->recv($newmsg, $MAXLEN)) {
    my($port, $ipaddr) = sockaddr_in($sock->peername);
    print "Befehl von Client: $newmsg\n";
    ($data) = "";
    $res = $dbh->selectall_arrayref("$newmsg;") or die "Couldn't prepare statement: " . $dbh->errstr;
    foreach my $row (@$res) {
    ($data) = @$row;
    $sock->send(decode("utf-8","|$data"));
    } }
    die "recv: $!";
    $dbh->disconnect();

    Wie muss ich die Ausgabe an den Socket ändern?
    Hast Du eine Idee...

    Klaus

    Kommentar


      #17
      Hallo Sascha,

      hab versucht auf udp umzustellen und erhalte folgendes Ergebnis:

      19:53:33.628 - network: udp message from 192.168.2.40, size 64 bytes
      19:53:33.629 - parser: parsing sequence: <UDP.SOCK><SEND=SELECT c00 FROM movie WHERE c07=2006></UDP.SOCK>
      19:53:33.630 - parser: command: UDP.SOCK - SEND=SELECT c00 FROM movie WHERE c07=2006
      19:53:33.630 - parser: reply sequence: <UDP.SOCK>SEND=|OK</UDP.SOCK>
      19:53:33.633 - commandserver: UDP send: 192.168.2.20:8000 data: SELECT c00 FROM movie WHERE c07=2006
      19:53:33.638 - commandserver: UDP receive: 192.168.2.20:8000 data: |16 Blocks
      19:53:33.640 - commandserver: translated reply sequence: <UDP.SOCK>|16 Blocks|OK</UDP.SOCK>
      19:53:33.648 - network: message parsed
      19:53:33.666 - commandserver: UDP receive: 192.168.2.20:8000 data: |300
      19:53:33.670 - commandserver: translated reply sequence: <UDP.SOCK>|300|OK</UDP.SOCK>
      19:53:33.688 - commandserver: UDP receive: 192.168.2.20:8000 data: |An Inconvenient Truth
      19:53:33.690 - commandserver: translated reply sequence: <UDP.SOCK>|An Inconvenient Truth|OK</UDP.SOCK>
      19:53:33.707 - commandserver: UDP receive: 192.168.2.20:8000 data: |Babel
      19:53:33.708 - commandserver: translated reply sequence: <UDP.SOCK>|Babel|OK</UDP.SOCK>
      19:53:33.726 - commandserver: UDP receive: 192.168.2.20:8000 data: |Blood Diamond
      19:53:33.727 - commandserver: translated reply sequence: <UDP.SOCK>|Blood Diamond|OK</UDP.SOCK>
      19:53:33.744 - commandserver: UDP receive: IP:8000 data: |Das Leben der Anderen
      19:53:33.746 - commandserver: translated reply sequence: <UDP.SOCK>|Das Leben der Anderen|OK</UDP.SOCK>
      19:53:33.763 - commandserver: UDP receive: IP:8000 data: |Deja Vu
      19:53:33.765 - commandserver: translated reply sequence: <UDP.SOCK>|Deja Vu|OK</UDP.SOCK>
      19:53:33.782 - commandserver: UDP receive: IP:8000 data: |Dreamgirls
      19:53:33.783 - commandserver: translated reply sequence: <UDP.SOCK>|Dreamgirls|OK</UDP.SOCK>
      19:53:33.800 - commandserver: UDP receive: IP:8000 data: |Pirates of the Caribbean: Dead Man's Chest
      19:53:33.802 - commandserver: translated reply sequence: <UDP.SOCK>|Pirates of the Caribbean: Dead Man's Chest|OK</UDP.SOCK>
      19:53:33.819 - commandserver: UDP receive: IP:8000 data: |Hollywoodland
      19:53:33.821 - commandserver: translated reply sequence: <UDP.SOCK>|Hollywoodland|OK</UDP.SOCK>
      19:53:33.838 - commandserver: UDP receive: IP:8000 data: |The Departed
      19:53:33.839 - commandserver: translated reply sequence: <UDP.SOCK>|The Departed|OK</UDP.SOCK>
      19:53:33.860 - commandserver: UDP receive: IP:8000 data: |The Good Shepherd
      19:53:33.862 - commandserver: translated reply sequence: <UDP.SOCK>|The Good Shepherd|OK</UDP.SOCK>
      19:53:33.880 - commandserver: UDP receive: IP:8000 data: |The Prestige
      19:53:33.882 - commandserver: translated reply sequence: <UDP.SOCK>|The Prestige|OK</UDP.SOCK>
      19:53:33.900 - commandserver: UDP receive: IP:8000 data: |Volver
      19:53:33.901 - commandserver: translated reply sequence: <UDP.SOCK>|Volver|OK</UDP.SOCK>
      19:53:33.918 - commandserver: UDP receive: IP:8000 data: |Cars
      19:53:33.920 - commandserver: translated reply sequence: <UDP.SOCK>|Cars|OK</UDP.SOCK>
      19:53:33.937 - commandserver: UDP receive: IP:8000 data: |The Da Vinci Code
      19:53:33.939 - commandserver: translated reply sequence: <UDP.SOCK>|The Da Vinci Code|OK</UDP.SOCK>
      19:53:33.956 - commandserver: UDP receive: IP:8000 data: |Penelope
      19:53:33.958 - commandserver: translated reply sequence: <UDP.SOCK>|Penelope|OK</UDP.SOCK>
      19:53:33.975 - commandserver: UDP receive: IP:8000 data: |Rescue Dawn
      19:53:33.976 - commandserver: translated reply sequence: <UDP.SOCK>|Rescue Dawn|OK</UDP.SOCK>
      19:53:33.994 - commandserver: UDP receive: IP:8000 data: |Notebook
      19:53:33.995 - commandserver: translated reply sequence: <UDP.SOCK>|Notebook|OK</UDP.SOCK>
      19:53:34.012 - commandserver: UDP receive: IP:8000 data: |Trixie
      19:53:34.015 - commandserver: translated reply sequence: <UDP.SOCK>|Trixie|OK</UDP.SOCK>

      Jetzt kommt jeder Titel einzeln.

      Im Terminal sieht das Ergebnis der Sqlite Abfrage so aus:
      |16 Blocks|300|An Inconvenient Truth|Babel|Blood Diamond|Das Leben der Anderen|Deja Vu|Dreamgirls|Pirates of the Caribbean: Dead Man's Chest|Hollywoodland|The Departed|The Good Shepherd|The Prestige|Volver|Cars|The Da Vinci Code|Penelope|Rescue Dawn|Notebook|Trixie

      Das Perl Script für den Server:

      # UDP message server
      use strict;
      use DBI;
      use IO::Socket;
      use Encode qw(decode);

      # Datenbank
      my $dbargs = {AutoCommit => 0, PrintError => 1};
      my $dbh = DBI->connect("dbi:SQLite:dbname=MyVideos34.db", "", "", $dbargs);

      my($data, $sock, $res, $newmsg, $MAXLEN, $PORTNO);

      $MAXLEN = 1024;
      $PORTNO = 8000;

      $sock = IO::Socket::INET->new(LocalPort => $PORTNO, Proto => 'udp')
      or die "socket: $@";
      print "Warte auf UDP Nachricht von Port $PORTNO\n";
      while ($sock->recv($newmsg, $MAXLEN)) {
      my($port, $ipaddr) = sockaddr_in($sock->peername);
      print "Befehl von Client: $newmsg\n";
      ($data) = "";
      $res = $dbh->selectall_arrayref("$newmsg;") or die "Couldn't prepare statement: " . $dbh->errstr;
      foreach my $row (@$res) {
      ($data) = @$row;
      $sock->send(decode("utf-8","|$data"));
      } }
      die "recv: $!";
      $dbh->disconnect();

      Wie muss ich die Ausgabe an den Socket ändern?
      Hast Du eine Idee...

      Klaus

      Kommentar


        #18
        Hallo Klaus,

        ich habe mit Perl eigentlich nichts am Hut, aber versuche mal Folgendes:
        Code:
        [...]
        $res = $dbh->selectall_arrayref("$newmsg;") or die "Couldn't prepare statement: " . $dbh->errstr;
        ($senddata) = "";
        foreach my $row (@$res) {
        ($data) = @$row;
        $senddata = "${senddata}|${data}";
        } 
        $sock->send(decode("utf-8","$senddata"));
        }
        die "recv: $!";
        $dbh->disconnect();
        Gruß

        Sascha

        Kommentar


          #19
          Hallo Sascha,

          funktioniert. Das Ergebnis der Abfrage kommt jetzt in mmh wie folgt an:

          10:05:25.713 - network: udp message from IP, size 32 bytes
          10:05:25.716 - parser: parsing sequence: <UDP.SOCK><JAHR=2006></UDP.SOCK>
          10:05:25.718 - parser: command: UDP.SOCK - JAHR=2006
          10:05:25.718 - parser: reply sequence: <UDP.SOCK>JAHR=|OK</UDP.SOCK>
          10:05:25.719 - commandserver: UDP send: IP:8002 data: SELECT c00 FROM movie WHERE c07=(2006)
          10:05:25.736 - commandserver: UDP receive: IP:8002 data: |16 Blocks|300|An Inconvenient Truth|Babel|Blood Diamond|Das Leben der Anderen|Deja Vu|Dreamgirls|Pirates of the Caribbean: Dead Man's Chest|Hollywoodland|The Departed|The Good Shepherd|The Prestige|Volver|Cars|The Da Vinci Code|Penelope|Rescue Dawn|Notebook|Trixie
          10:05:25.739 - commandserver: translated reply sequence: <UDP.SOCK>|16 Blocks|300|An Inconvenient Truth|Babel|Blood Diamond|Das Leben der Anderen|Deja Vu|Dreamgirls|Pirates of the Caribbean: Dead Man's Chest|Hollywoodland|The Departed|The Good Shepherd|The Prestige|Volver|Cars|The Da Vinci Code|Penelope|Rescue Dawn|Notebook|Trixie|OK</UDP.SOCK>
          10:05:25.742 - network: message parsed

          Der Commandserver:

          [CONFIG];
          ACTIVE;YES
          SERVERIP;xxx.xxx.xxx.xxx
          SERVERPORT;8002
          SERVERMODE;ASCII
          SERVERTIMEOUT;NONE
          SERVERPROTOCOL;UDP
          MATCHING=NORMAL


          [COMMANDS];
          SEND;\#;
          TITEL;SELECT c00 FROM movie
          JAHR;SELECT c00 FROM movie WHERE c07=(\#)
          INFO;SELECT c01 FROM movie WHERE c00=(\#)
          GENRE;SELECT c14 FROM movie WHERE c00=(\#)
          RATING;SELECT c05 FROM movie WHERE c00=(\#)

          [MAPPINGS];
          \?\*;DATEN

          Sobald ich unter Mappings was eintrage kommen keine Daten mehr rein.
          Auch bei \*;DATEN das gleiche Ergebnis.

          Was mach ich denn falsch?

          Klaus

          Kommentar


            #20
            Hallo Klaus,

            das kann ich Dir sagen:
            Der Match
            Code:
            \?\*;DATEN
            ist nicht terminiert. mmh weiß also nicht, bis wohin es matchen soll.
            Wenn Du den Reply-String eindeutig terminierst, z.B. mit
            Code:
            $senddata = "${senddata}|[END]";
            und dann dann den Match etwas umbaut, z.B. so:
            Code:
            |\*[END];DATEN
            bekommst Du auch gleich eine mmh-konforme Liste zurück.
            Gruß

            Sascha

            Kommentar


              #21
              Danke für die Hilfe Sascha. Jetzt funktioniert es.

              Da die thumbnails für die Filme und die Musik nicht in der Datenbank von xbmc sind hab ich noch einen udp socket für die neue json Anwendung aufgesetzt.

              Ich möchte nur die Zeile mit den thumbnails matchen und noch folgenden Text ergänzen:

              http://localhost:8080/vfs/special://masterprofile/Thumbnails/Video/5/56422853.tbn

              Der Commandserver:

              [CONFIG];
              ACTIVE;YES
              SERVERIP;xxx.xxx.xxx.xxx
              SERVERPORT;8003
              SERVERMODE;ASCII
              SERVERTIMEOUT;NONE
              SERVERPROTOCOL;UDP
              MATCHING=FULL
              //CMDSUFFIX;\0x0A


              [COMMANDS];
              SEND;\#;
              FILME;VideoLibrary.GetMovies '{ "start": 0, "end": 3 }'


              [MAPPINGS];
              //"thumbnail" : "\*"\0x0A|[END];DATEN;;;{%rspezial,http://localhost:8080/vfs/spezial}


              Log:

              15:32:10.594 - network: udp message from IP, size 30 bytes
              15:32:10.594 - parser: parsing sequence: <JSON.SOCK><FILME></JSON.SOCK>
              15:32:10.595 - parser: command: JSON.SOCK - FILME
              15:32:10.596 - parser: reply sequence: <JSON.SOCK>FILME=|OK</JSON.SOCK>
              15:32:10.597 - commandserver: UDP send: IP:8003 data: VideoLibrary.GetMovies '{ "start": 0, "end": 3 }'
              15:32:10.618 - network: message parsed
              15:32:10.981 - commandserver: UDP receive: IP:8003 data: /Users/kb/Desktop/xbmc.py\0x0AVideoLibrary.GetMovies\0x0A{ "start": 0, "end": 3 }\0x0A{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "start": 0, "end": 3 }, "id": "1"}\0x0A{\0x0A "id" : "1",\0x0A "jsonrpc" : "2.0",\0x0A "result" : {\0x0A "end" : 3,\0x0A "movies" : [\0x0A {\0x0A "file" : "/Volumes/Videos/16 BLOCKS (2006)/VIDEO_TS/VIDEO_TS.IFO",\0x0A "label" : "16 Blocks",\0x0A "movieid" : 1,\0x0A "thumbnail" : "special://masterprofile/Thumbnails/Video/5/56422853.tbn"\0x0A },\0x0A {\0x0A "file" : "/Volumes/Videos/27 DRESSES (2008)/VIDEO_TS/VIDEO_TS.IFO",\0x0A "label" : "27 Dresses",\0x0A "movieid" : 2,\0x0A "thumbnail" : "special://masterprofile/Thumbnails/Video/9/9521659b.tbn"\0x0A },\0x0A {\0x0A "file" : "/Volumes/Videos/300 (2006)/VIDEO_TS/VIDEO_TS.IFO",\0x0A "label" : "300",\0x0A "movieid" : 3,\0x0A "thumbnail" : "special://masterprofile/Thumbnails/Video/3/332b8f71.tbn"\0x0A }\0x0A ],\0x0A "start" : 0,\0x0A "total" : 238\0x0A }\0x0A}\0x0A\0x0A|[END]
              15:32:10.983 - commandserver: translated reply sequence: <JSON.SOCK>/Users/kb/Desktop/xbmc.py\0x0AVideoLibrary.GetMovies\0x0A{ "start": 0, "end": 3 }\0x0A{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "start": 0, "end": 3 }, "id": "1"}\0x0A{\0x0A "id" : "1",\0x0A "jsonrpc" : "2.0",\0x0A "result" : {\0x0A "end" : 3,\0x0A "movies" : [\0x0A {\0x0A "file" : "/Volumes/Videos/16 BLOCKS (2006)/VIDEO_TS/VIDEO_TS.IFO",\0x0A "label" : "16 Blocks",\0x0A "movieid" : 1,\0x0A "thumbnail" : "special://masterprofile/Thumbnails/Video/5/56422853.tbn"\0x0A },\0x0A {\0x0A "file" : "/Volumes/Videos/27 DRESSES (2008)/VIDEO_TS/VIDEO_TS.IFO",\0x0A "label" : "27 Dresses",\0x0A "movieid" : 2,\0x0A "thumbnail" : "special://masterprofile/Thumbnails/Video/9/9521659b.tbn"\0x0A },\0x0A {\0x0A "file" : "/Volumes/Videos/300 (2006)/VIDEO_TS/VIDEO_TS.IFO",\0x0A "label" : "300",\0x0A "movieid" : 3,\0x0A "thumbnail" : "special://masterprofile/Thumbnails/Video/3/332b8f71.tbn"\0x0A }\0x0A ],\0x0A "start" : 0,\0x0A "total" : 238\0x0A }\0x0A}\0x0A\0x0A|[END]|OK</JSON.SOCK>

              Klaus

              Kommentar


                #22
                Hallo Sascha,

                hab nochmal ein ähnliches Problem für die Abfrage einer mysql Datenbank.
                Habe für xbmc jetzt eine zentrale Datenbank für alle Clients und möchte diese Abfragen und auf den Socket senden.
                Bin wieder an der Stelle wo die Daten einzeln reinkommen und kann Deine Lösung nicht auf das neue Script übertragen.


                Zitat von no sleep Beitrag anzeigen
                Hallo Klaus,

                ich habe mit Perl eigentlich nichts am Hut, aber versuche mal Folgendes:
                Code:
                [...]
                $res = $dbh->selectall_arrayref("$newmsg;") or die "Couldn't prepare statement: " . $dbh->errstr;
                ($senddata) = "";
                foreach my $row (@$res) {
                ($data) = @$row;
                $senddata = "${senddata}|${data}";
                } 
                $sock->send(decode("utf-8","$senddata"));
                }
                die "recv: $!";
                $dbh->disconnect();
                Auszug aus dem Script:

                ## UDP Socket
                my($data, $dbh, $senddata, $query, $sqlQuery, $sock, $row, $res, $newmsg, $MAXLEN, $PORTNO);

                $MAXLEN = 1024;
                $PORTNO = 49000;

                $sock = IO::Socket::INET->new(LocalPort => $PORTNO, Proto => 'udp')
                or die "socket: $@";
                print "Warte auf UDP Nachricht von Port $PORTNO\n";
                while ($sock->recv($newmsg, $MAXLEN)) {
                my($port, $ipaddr) = sockaddr_in($sock->peername);
                print "Befehl von Client: $newmsg\n";

                ## SQL query
                $query = "$newmsg";

                $dbh = DBI->connect("DBI:mysql:$db:$host", $user, $pass);
                $sqlQuery = $dbh->prepare($query)
                or die "Can't prepare $query: $dbh->errstr\n";

                my $rv = $sqlQuery->execute
                or die "can't execute the query: $sqlQuery->errstr";

                while (my @row= $sqlQuery->fetchrow_array()) {
                my $tables = $row[0];
                $sock->send(decode("utf-8","$newmsg=$tables|[END]"));
                }
                my $rc = $sqlQuery->finish;
                }

                die "recv: $!";

                Wie muss ich die Daten auf die Reise schicken damit das Ganze in einem string gesendet wird?

                Klaus

                Kommentar


                  #23
                  Da war ich zu ungeduldig.
                  Jetzt funktionierts.

                  Kann jetzt auf die Datenbank von XBMC über mmh zugreifen und in iviewer in Listenform darstellen.

                  Sobald ich noch ein bißchen getestet habe poste ich ein paar screenshots.

                  Klaus

                  Kommentar


                    #24
                    Meinen vollen Respekt!!!

                    Ist denn nun noch Bedarf auf Seiten der Listen?

                    Kommentar


                      #25
                      Für die Darstellung der Thumbnails fehlt mir noch der match:
                      Ich würde gerne die zuletzt hinzugefügten 25 Filme mit den thumbs darstellen. Aus der Liste will ich nur die URLs der Thumbnails ergänzt um etwas Text.

                      [MAPPINGS];
                      //"thumbnail" : "\*"\0x0A|[END];DATEN;;;{%rspezial,http://localhost:8080/vfs/spezial}


                      Log:

                      15:32:10.594 - network: udp message from IP, size 30 bytes
                      15:32:10.594 - parser: parsing sequence: <JSON.SOCK><FILME></JSON.SOCK>
                      15:32:10.595 - parser: command: JSON.SOCK - FILME
                      15:32:10.596 - parser: reply sequence: <JSON.SOCK>FILME=|OK</JSON.SOCK>
                      15:32:10.597 - commandserver: UDP send: IP:8003 data: VideoLibrary.GetMovies '{ "start": 0, "end": 3 }'
                      15:32:10.618 - network: message parsed
                      15:32:10.981 - commandserver: UDP receive: IP:8003 data: /Users/kb/Desktop/xbmc.py\0x0AVideoLibrary.GetMovies\0x0A{ "start": 0, "end": 3 }\0x0A{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "start": 0, "end": 3 }, "id": "1"}\0x0A{\0x0A "id" : "1",\0x0A "jsonrpc" : "2.0",\0x0A "result" : {\0x0A "end" : 3,\0x0A "movies" : [\0x0A {\0x0A "file" : "/Volumes/Videos/16 BLOCKS (2006)/VIDEO_TS/VIDEO_TS.IFO",\0x0A "label" : "16 Blocks",\0x0A "movieid" : 1,\0x0A "thumbnail" : "special://masterprofile/Thumbnails/Video/5/56422853.tbn"\0x0A },\0x0A {\0x0A "file" : "/Volumes/Videos/27 DRESSES (2008)/VIDEO_TS/VIDEO_TS.IFO",\0x0A "label" : "27 Dresses",\0x0A "movieid" : 2,\0x0A "thumbnail" : "special://masterprofile/Thumbnails/Video/9/9521659b.tbn"\0x0A },\0x0A {\0x0A "file" : "/Volumes/Videos/300 (2006)/VIDEO_TS/VIDEO_TS.IFO",\0x0A "label" : "300",\0x0A "movieid" : 3,\0x0A "thumbnail" : "special://masterprofile/Thumbnails/Video/3/332b8f71.tbn"\0x0A }\0x0A ],\0x0A "start" : 0,\0x0A "total" : 238\0x0A }\0x0A}\0x0A\0x0A|[END]
                      15:32:10.983 - commandserver: translated reply sequence: <JSON.SOCK>/Users/kb/Desktop/xbmc.py\0x0AVideoLibrary.GetMovies\0x0A{ "start": 0, "end": 3 }\0x0A{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "start": 0, "end": 3 }, "id": "1"}\0x0A{\0x0A "id" : "1",\0x0A "jsonrpc" : "2.0",\0x0A "result" : {\0x0A "end" : 3,\0x0A "movies" : [\0x0A {\0x0A "file" : "/Volumes/Videos/16 BLOCKS (2006)/VIDEO_TS/VIDEO_TS.IFO",\0x0A "label" : "16 Blocks",\0x0A "movieid" : 1,\0x0A "thumbnail" : "special://masterprofile/Thumbnails/Video/5/56422853.tbn"\0x0A },\0x0A {\0x0A "file" : "/Volumes/Videos/27 DRESSES (2008)/VIDEO_TS/VIDEO_TS.IFO",\0x0A "label" : "27 Dresses",\0x0A "movieid" : 2,\0x0A "thumbnail" : "special://masterprofile/Thumbnails/Video/9/9521659b.tbn"\0x0A },\0x0A {\0x0A "file" : "/Volumes/Videos/300 (2006)/VIDEO_TS/VIDEO_TS.IFO",\0x0A "label" : "300",\0x0A "movieid" : 3,\0x0A "thumbnail" : "special://masterprofile/Thumbnails/Video/3/332b8f71.tbn"\0x0A }\0x0A ],\0x0A "start" : 0,\0x0A "total" : 238\0x0A }\0x0A}\0x0A\0x0A|[END]|OK</JSON.SOCK>

                      Gewünschtes Ergebnis:

                      <JSON.SOCK><THUMBS=http://localhost:8080/vfs/://masterprofile/Thumbnails/Video/3/332b8f71.tbn|...</JSON.SOCK>

                      Klaus

                      Kommentar


                        #26
                        Hallo Mike,

                        die Thumbnails von xbmc liegen ja lokal auf der Festplatte unter:

                        /Users/Benutzer/Library/Application Support/XBMC/userdata/Thumbnails

                        Leider ist der Pfad nicht in der Datenbank hinterlegt. Die Thumbnails werden lt. XBMC Wiki so erstellt...

                        Hashing

                        The thumbnail .tbn file is created via a hashing function. As explained earlier, the hash is based off the CRC32 of the pathname (plus filename) in lowercase. Files which are local are hashed using their drive letter. Remote files are hashed using the smb:// protocol designation and optional username and password.
                        Examples
                        123456789 returns 0376e6e7
                        F:\Videos\Nosferatu.avi returns 2a6ec78d
                        smb://userass@server/share/directory/ returns c5559f13
                        smb://userass@server/share/directory/file.ext returns 8ce36055
                        Remember:
                        When hashing remote shares, use the path as displayed in the sources.xml file, which can include the username and password.
                        When hashing directories for thumbnails, include the final slash.
                        Sample Code
                        The following code is written in C# and produces the same output as the XBMC hashing function.
                        public string Hash(string input)
                        {
                        char[] chars = input.ToCharArray();
                        for (int index = 0; index < chars.Length; index++)
                        {
                        if (chars[index] <= 127)
                        {
                        chars[index] = System.Char.ToLowerInvariant(chars[index]);
                        }
                        }
                        input = new string(chars);
                        uint m_crc = 0xffffffff;
                        byte[] bytes = System.Text.Encoding.UTF8.GetBytes(input);
                        foreach (byte myByte in bytes)
                        {
                        m_crc ^= ((uint)(myByte) << 24);
                        for (int i = 0; i < 8; i++)
                        {
                        if ((System.Convert.ToUInt32(m_crc) & 0x80000000) == 0x80000000)
                        {
                        m_crc = (m_crc << 1) ^ 0x04C11DB7;
                        }
                        else
                        {
                        m_crc <<= 1;
                        }
                        }
                        }
                        return String.Format("{0:x8}", m_crc);
                        }

                        Über die Datenbank können wir ja den Pfad des Films abfragen. Kann mmh daraus den Namen des thumbnails.png errechnen?
                        Die JSON Abfrage funktioniert nur wenn xbmc auch läuft.

                        Zum starten eines Films fehlt mir noch der Pfad an der richtigen Stelle.

                        mremote.csv

                        515;#;<SYS><OPEN=-a /Applications/XBMC.app></SYS>;GENRE=\*OK;;NOCACHE //XBMC Korrekter Pfad zum Film fehlt noch

                        Habt ihr was rausgefunden wegen den "" im Befehl die beim versenden von mmh verschluckt werden?

                        <SYS><OPEN=open -a /Applications/XBMC.app "/Pfad"></SYS>;

                        Den Pfad krieg ich jetzt mit einer Abfrage aus der Datenbank;
                        <UDP.SOCK><ONEFILE='300'></UDP.SOCK>
                        <UDP.SOCK>ONEFILE=/Volumes/Videos/300 (2006)/VIDEO_TS/VIDEO_TS.IFO|OK</UDP.SOCK>

                        Wie muss ich das in der mremote.csv definieren damit der Pfad an der richtigen Stelle übergeben wird?

                        Klaus

                        Kommentar


                          #27
                          Habt ihr was rausgefunden wegen den "" im Befehl die beim versenden von mmh verschluckt werden?
                          Die werden absichtlich unterdrückt ... aber ich hab GEKÄMPFT !!! und durchgesetzt, dass dies wieder freigeschaltet wird...

                          Also, auf die nächste Release warten....

                          P.S.: Mit den Thumbnails verstehe ich zwar was Du willst, aber noch ict mir nihct ganz klar, wie ich an die Informationen kommen soll...

                          Kommentar


                            #28
                            scripting client lädt commandserver nicht mehr

                            Hallo,

                            die commands werden vom scripting client nicht mehr geladen.
                            Das Problem trat auf nachdem ich den command DIR hinzugefügt hatte.
                            Ohne die Zeile geht es wie gewünscht.

                            Jemand eine Idee?


                            commandserver:

                            [CONFIG];
                            ACTIVE;YES
                            SERVERIP;IP
                            SERVERPORT;49221
                            SERVERMODE;ASCII
                            SERVERTIMEOUT;3
                            SERVERPROTOCOL;UDP
                            MATCHING=FULL


                            [COMMANDS];
                            SUCHE;SELECT c00 FROM movie WHERE c00 LIKE ('%\#%') ORDER BY c00
                            TIT;SELECT c00 FROM movie WHERE idMovie=('\#')
                            NEU;SELECT c00 FROM movie ORDER BY c00 DESC LIMIT 5
                            FILMJAHR;SELECT c00 FROM movie WHERE c07=(\#)
                            FILMDAUER;SELECT c11 FROM movie WHERE idMovie=('\#')
                            INFO;SELECT c01 FROM movie WHERE idMovie=('\#')
                            KURZINFO;SELECT REPLACE(c02,',', '') FROM movie WHERE idMovie=('\#')
                            GENRE;SELECT c00 FROM movieview WHERE c14 LIKE ('%\#%') ORDER BY c00
                            MOVIEID;SELECT idMovie FROM movieview WHERE c14 LIKE ('%\#%') ORDER BY c00
                            GENRELIST;SELECT strGenre FROM genre ORDER BY strGenre
                            RATING;SELECT c05 FROM movie WHERE idMovie=('\#')
                            PFAD;SELECT CONCAT(strPath,'',strFileName) FROM movieview WHERE idMovie=('\#')
                            URL;SELECT REPLACE(CONCAT(strPath,'',strFileName),' ', '%20') FROM movieview WHERE idMovie=('\#')
                            COVER;COVER('\#')
                            THUMBSNEU;THUMBSNEU
                            FANART;FANART('\#')
                            CF;SELECT idMovie FROM movie ORDER BY c00 DESC LIMIT 9
                            DIR;SELECT c06 FROM movie WHERE idMovie=('\#')

                            [MAPPINGS];
                            SELECT c00 FROM movie WHERE c00 LIKE\%|\*|[END];SUCHE
                            SELECT c06\%|\*|[END];DIR
                            SELECT c00 FROM movie WHERE idMovie=\%|\*|[END];TIT
                            SELECT c00 FROM movie ORDER BY c00\%|\*|[END];NEU
                            SELECT c00 FROM movie WHERE c07=\%|\*|[END];FILMJAHR
                            SELECT c11 FROM movie WHERE idMovie=\%|\*|[END];FILMDAUER
                            SELECT strGenre FROM genre\%|\*|[END];GENRELIST
                            SELECT c00 FROM movieview WHERE c14 LIKE\%|\*|[END];GENRE
                            SELECT idMovie FROM movieview WHERE c14 LIKE\%|\*|[END];MOVIEID
                            SELECT c01 FROM movie WHERE idMovie=\%|\*|[END];INFO
                            SELECT REPLACE(c02,',', '') FROM movie WHERE idMovie=\%|\*|[END];KURZINFO

                            Gruß
                            Klaus

                            Kommentar


                              #29
                              DIR;SELECT c06 FROM movie WHERE idMovie=('\#')
                              Diese?! und wenn Du den Befehl mal DIR_ nennst... aber das kann es eigentlich nicht sein. Was sagt den das LOG nach dem RESTARTSERVICE ??

                              LG

                              Kommentar


                                #30
                                DIR_ hilft nicht. Hab auch schon verschiedene Bezeichnungen probiert.
                                mmh lädt die Commandliste einfach nicht mehr.
                                Im Log steht allerdings was anderes. Im Scripting Client sehe ich in der Klasse UDP.SOCK keine Commands lediglich ein Häkchen im Drop Down Feld.

                                ???

                                Klaus

                                Log:

                                19:20:26.296 - mRemote: received sequence: h=0\0x03
                                19:20:26.296 - mRemote: sending sequence: h=1\0x03
                                19:20:29.485 - network: udp message from IP, size 27 bytes
                                19:20:29.485 - parser: parsing sequence: <SYS><RESTARTSERVICE></SYS>
                                19:20:29.487 - parser: command: SYS - RESTARTSERVICE
                                19:20:29.487 - parser: reply sequence: <SYS>RESTARTSERVICE=|OK</SYS>
                                19:20:29.505 - network: message parsed
                                19:20:30.316 - mRemote: received sequence: h=0\0x03
                                19:20:30.316 - mRemote: sending sequence: h=1\0x03
                                19:20:30.428 - system: exiting cleanly
                                19:20:30.690 - knx: device IP disconnected
                                19:20:54.296 - mRemote: received sequence: h=0\0x03
                                19:20:54.296 - mRemote: sending sequence: h=1\0x03
                                19:20:56.469 - network: udp message from IP, size 35 bytes
                                19:20:56.470 - parser: parsing sequence: <SYS><GETSRVLIST><GETXPLLIST></SYS>
                                19:20:56.471 - parser: command: SYS - GETSRVLIST
                                19:20:56.471 - parser: command: SYS - GETXPLLIST
                                19:20:56.471 - parser: reply sequence: <SYS>GETSRVLIST=IRTRANS|UDP.SOCK|XBMC|OK|GETXPLLIS T=SLIMSERVER|OK</SYS>
                                19:20:56.487 - network: message parsed
                                19:20:56.584 - network: udp message from IP, size 37 bytes
                                19:20:56.585 - parser: parsing sequence: <SLIMSERVER><GETCMDLIST></SLIMSERVER>
                                19:20:56.586 - network: udp message from IP, size 31 bytes
                                19:20:56.587 - parser: command: SLIMSERVER - GETCMDLIST
                                19:20:56.587 - parser: reply sequence: <SLIMSERVER>GETCMDLIST=PLAY|STOP|VOLUME#|NEXT|PREV |RANDOM|CLEAR|PAUSETOGGLE|PAUSEON|PAUSEOFF|PLAYFIL E#|SETPTIME#|SLEEP#|POWERON|POWEROFF|ADDANDPLAY#|A DDANDPLAYITUNES#|ADD#|INSERT#|MOVE#|DELETE#|RESUME #|SAVE#|LOADALBUM#|ADDALBUM#|JUMP#|SHUFFLEON|SHUFF LEOFF|NOREPEAT|REPEATSONG|REPEATPLAYLIST|RESCAN|OK </SLIMSERVER>
                                19:20:56.592 - parser: parsing sequence: <IRTRANS><GETCMDLIST></IRTRANS>
                                19:20:56.593 - network: udp message from IP, size 33 bytes
                                19:20:56.594 - parser: parsing sequence: <UDP.SOCK><GETCMDLIST></UDP.SOCK>
                                19:20:56.599 - parser: command: IRTRANS - GETCMDLIST
                                19:20:56.600 - parser: reply sequence: <IRTRANS>GETCMDLIST=POWER|PC|OFF|TV|OK</IRTRANS>
                                19:20:56.601 - network: udp message from IP, size 25 bytes
                                19:20:56.602 - parser: parsing sequence: <XBMC><GETCMDLIST></XBMC>
                                19:20:56.603 - parser: command: UDP.SOCK - GETCMDLIST
                                19:20:56.603 - parser: reply sequence: <UDP.SOCK>GETCMDLIST=SUCHE#|TIT#|NEU|FILMJAHR#|FIL MDAUER#|INFO#|KURZINFO#|GENRE#|MOVIEID#|GENRELIST| RATING#|PFAD#|URL#|COVER#|THUMBSNEU|FANART#|CF|DIR #|OK</UDP.SOCK>
                                19:20:56.609 - parser: command: XBMC - GETCMDLIST
                                19:20:56.609 - parser: reply sequence: <XBMC>GETCMDLIST=ACTION#|PAUSE|NEXT|PREV|PLAY_FILE #|RESET|RESTART|RESTART_APP|ROTATE|SENDKEY#|SHOWPI CTURE#|SHUTDOWN|SPINDOWN|STOP|ZOOM#|ENABLEBROADCAS T|DISABLEBROADCAST|GETBROADCAST|GETSHARES#|GETCURR ENTPLAYLIST|CREATETHUMBNAIL|GETCURRENTSLIDE|GETMOV IEDETAILS#|GETPERCENTAGE|GETPLAYLISTLENGTH#|GETPLA YLISTSONG|GETPLAYSPEED|GETMUSICLABEL#|GETRECORDSTA TUS|GETVIDEOLABEL#|GETSLIDESHOWCONTENTS|GETTAGFROM FILENAME#|GETVOLUME|TOGGLEMUTE|SETPLAYLISTSONG#|SE TVOLUME#|VIDEODATENBANK#|OK</XBMC>
                                19:20:56.618 - network: message parsed
                                19:20:56.632 - network: message parsed
                                19:20:56.645 - network: message parsed
                                19:20:56.657 - network: message parsed
                                19:20:58.316 - mRemote: received sequence: h=0\0x03
                                19:20:58.316 - mRemote: sending sequence: h=1\0x03

                                Kommentar

                                Lädt...
                                X