Autor Beitrag
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: So 10.07.05 13:24 
Hi Leute. Ich mache folgendes:
Ein PHPscript, dass ich nicht selber geschrieben habe, nur leicht verändert, liegt auf einem Server. hier. Wie ihr, wenn RMC grade online ist, seht, liefert es Streamtitle, Zuhörerzahl und ähnliches zurück. Getrennt durch ;;. Aufgerufen wird es mit dieser Routine:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
Procedure TForm1.Refresh;
Var
    titel, moderator, hoerer: String;
    //i: Integer;
    DJ: Boolean;
Begin
    Panel1.Visible := true;
    Application.Processmessages;
    Form1.Caption := 'RMC-Tool by JayEff ' + v + ' [Aktualisierung...]';
    CoolTrayIcon1.Hint := '[Aktualisierung...] *nichts geht mehr :( *';

    s.text := IdHTTP1.Get('http://rigismusiccity.de/rmctool/rmcstatustool.php');
    s.savetofile(ExtractFilePath(Application.ExeName) + 'temp.txt');
    s.text := StringReplace(s.text, ';;'#13#10, [rfReplaceAll]);//ich weis, geht auch mit Delimiter und CommaText. So ists mir iwie sicherer.
    s.text := StringReplace(s.text, 'ü''ü', [rfReplaceAll]);
    If length(s.text) > 0 Then
    Begin
        Try
            If s[6] = '1' Then
            Begin
                erstesmalballoff := true;
                moderator := StringReplace(s[5], 'Rigi's Music-City © by Bulldog Record's -''', [rfIgnoreCase, rfReplaceAll]);
                moderator := StringReplace(moderator, '- Rigi''s Music-City © by Bulldog Record''s -''', [rfIgnoreCase, rfReplaceAll]);
                titel := StringReplace(s[4], ''''''', [rfReplaceAll]);
                hoerer := 'DSL: ' + s[0] + ' (Rekord: ' + s[1] + ')' + #13#10 + 'ISDN: ' + s[2] + ' (Rekord: ' + s[3] + ')';
                Label5.Caption := 'Moderator: ' + moderator;
                Label4.Caption := titel;
                Label8.Caption := 'Zuhörer: ' + #13#10 + hoerer;
                Form1.CoolTrayIcon1.Hint := titel + ' - Euer DJ: ' + moderator;
                If showballon And showAkt Then
                    CoolTrayIcon1.ShowBalloonHint('RMC', titel + ' - Euer DJ: ' + moderator, bitInfo, 10);
                Form1.CoolTrayIcon1.IconIndex := 1;
                //                Form1.Button1.Enabled := true;
                Form1.Button6.Enabled := true;
                Form1.Button7.Enabled := true;
                DJ := favouriteDJ(DJs, moderator);
                {For i := 0 To DJs.Count - 1 Do
                Begin
                    If pos(DJs[i], moderator) > 0 Then
                        DJ := true;
                End;}

                {                If showballon And showDJ and erstesmalballon And Not showAkt Then
                                Begin
                                    CoolTrayIcon1.ShowBalloonHint('RMC ist Online', titel + ' - Euer DJ: ' + moderator, bitInfo, 10);
                                    erstesmalballon := false;
                                End;}

                If DJ Then
                Begin
                    If erstesmal Then
                    Begin
                        If showballon And showDJ Then
                            CoolTrayIcon1.ShowBalloonHint('LieblingsDJ!''Dein LieblingsDJ ' + moderator + ' ist online!'#10#13'Er spielt gerade ' + titel, bitInfo, 10);
                        erstesmal := False;
                        If onDJ Then
                        Begin
                            //Form1.Show;
                            //bringtofront;
                            MessageBox(0, PChar('Dein LieblingsDJ ' + moderator + ' ist online!'), PChar('LieblingsDJ!'), MB_ICONINFORMATION);
                            //Form1.hide;
                        End;
                        Label5.Font.Color := clRed;
                        Label5.Font.Style := [fsBold];
                    End;
                    Form1.CoolTrayIcon1.Hint := titel + ' - LIEBLINGSDJ: ' + moderator;
                End
                Else
                Begin
                    Label5.Font.Color := clWhite;
                    erstesmal := true;
                    Label5.Font.Style := [];
                End;
            End
            Else
            Begin
                erstesmalballon := true;
                Form1.CoolTrayIcon1.Hint := 'RMC ist Offline';
                If showballon And erstesmalballoff And showOff Then
                Begin
                    erstesmalballoff := False;
                    CoolTrayIcon1.ShowBalloonHint('RMC''RMC ist Offline gegangen', bitInfo, 10);
                End;
                Form1.CoolTrayIcon1.IconIndex := 2;
                erstesmal := true;
                //                Form1.Button1.Enabled := false;
                Form1.Button6.Enabled := False;
                Form1.Button7.Enabled := False;
                moderator := 'RMC ist Offline';
                titel := '';
                hoerer := '';
                Label5.Caption := moderator;
                Label5.Font.Color := clWhite;
                Label1.Font.Style := [];
                Label4.Caption := titel;
                Label8.Caption := hoerer;
            End;
        Except
            On E: Exception Do
            Begin
                TLog.ELOG(E.Message);
                TLog.WLOG('Refresh fehlgeschlagen!');
                Label5.Caption := 'FEHLER beim Aktualisieren!';
                Label4.Caption := 'FEHLER beim Aktualisieren!';
                Label8.Caption := 'FEHLER beim Aktualisieren!';
                CoolTrayIcon1.Hint := 'FEHLER beim Aktualisieren!';
                CoolTrayIcon1.IconIndex := 0;
            End;

        End;
    End
    Else
    Begin
        TLog.WLOG('Refresh fehlgeschlagen! s.text war leer oO');
        Label5.Caption := 'FEHLER beim Aktualisieren!';
        Label4.Caption := 'FEHLER beim Aktualisieren!';
        Label8.Caption := 'FEHLER beim Aktualisieren!';
        CoolTrayIcon1.Hint := 'FEHLER beim Aktualisieren!';
        CoolTrayIcon1.IconIndex := 0;
    End;
    Form1.Caption := 'RMC-Tool by JayEff ' + v;
    Panel1.Visible := False;
End;{langer text, ich weis, hier nochmal reduziert auf die wesentlichen stellen:}

    s.text := IdHTTP1.Get('http://rigismusiccity.de/rmctool/rmcstatustool.php');
    s.savetofile(ExtractFilePath(Application.ExeName) + 'temp.txt');
    s.text := StringReplace(s.text, ';;'#13#10, [rfReplaceAll]);
    s.text := StringReplace(s.text, 'ü''ü', [rfReplaceAll]);
    If length(s.text) > 0 Then
    Begin
        Try
            If s[6] = '1' Then
            Begin
            end;

        Except
            On E: Exception Do
            Begin
                TLog.ELOG(E.Message);
                TLog.WLOG('Refresh fehlgeschlagen!');
                Label5.Caption := 'FEHLER beim Aktualisieren!';
                Label4.Caption := 'FEHLER beim Aktualisieren!';
                Label8.Caption := 'FEHLER beim Aktualisieren!';
                CoolTrayIcon1.Hint := 'FEHLER beim Aktualisieren!';
                CoolTrayIcon1.IconIndex := 0;
            End;
        End;

Das blöde: während ein Aufruf über den Browser immer das richtige ergebnis liefert, liefert mein Programm sowas hier:
ausblenden Quelltext
1:
2:
<HTML><HEAD><TITLE>SHOUTcast Server</TITLE></HEAD><BODY><H3>Invalid resource</H3>
</BODY></HTML>

Ich verstehe nicht warum! der allererster aufruf der Routiene funktioniert und liefert exakt das erwünschte Errgebnis, aber jeder darauf folgende nicht!
Könnt ihr mir helfen?

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: So 10.07.05 13:52 
Das hört sich so an, als würde der Server nicht damit klarkommen, wenn die Verbindung bestehen bleibt. Hilft es, vor das Connect noch ein
if IdHTTP1.Connected then IdHTTP1.Disconnect;
zu schreiben?

Gruß,
maxk

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
JayEff Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: So 10.07.05 17:01 
Hm.. Ich rufe garkeine Connect auf, was dsa idHTTP1 betrifft... Ich habe jetzt vor dem verbinden und danach ein Connect -> Disconnect geschrieben... mal schaun... Ich versuche erst mal ohne, um zu sehen, ob der Fehler vielleicht nur ausserhalb der IDE auftritt (hatten wir alles schon... und das lag NICHT an Try-Except-end;s!)
Also ohne die connect codes klappt alles perfekt in der IDE, mit kommen "Verbindung abgelehnt" fehler... und zwar einmal, ganz am anfang. Warum auch immer.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
    Try
        If Not IdHTTP1.Connected Then
            IdHTTP1.Connect();
        s.text := IdHTTP1.Get('http://rigismusiccity.de/rmctool/rmcstatustool.php');
        If IdHTTP1.Connected Then
            IdHTTP1.Disconnect;
    Finally
    End;
Sogar dieser code gibt eine Fehlermeldung aus. Sogar ausserhalb der IDE.
Ich hänge euch mal das Programm als ZIP an...
edit: warum hat ers nicht angehängt??
Einloggen, um Attachments anzusehen!
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: So 10.07.05 17:30 
Nein! Ich meinte das schon so ;) Durch den Aufruf von Get veranlasst du automatisch den richtigen Host und Port einzutragen und die Verbindung herzustellen. Allerdings versucht die Komponente evtl. ein Keep-Alive (kA, wie man das besser formuliert), wodurch es nötig ist, manuell zu trennen...

Gruß,
maxk

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
JayEff Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Di 12.07.05 16:01 
ok werds versuchen.
edit:
Nix. keine verbesserung. mein Code:
ausblenden Delphi-Quelltext
1:
2:
3:
    If IdHTTP1.Connected Then
        IdHTTP1.disconnect();
    s.text := IdHTTP1.Get('http://rigismusiccity.de/rmctool/rmcstatustool.php');

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
stiftmaster
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 149



BeitragVerfasst: So 16.07.06 09:22 
user profile iconJayEff hat folgendes geschrieben:
Sogar dieser code gibt eine Fehlermeldung aus. Sogar ausserhalb der IDE.


Hi!

ich stecke grad genau an dem gleichen Problem. Hast du es schon lösen können? Wäre für jeden Tipp dankbar.

Thx

Stefan
JayEff Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: So 16.07.06 13:03 
Sorry, aber der Code
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
    Try
        If IdHTTP1.Connected Then
            IdHTTP1.disconnect();
        s.text := IdHTTP1.Get('http://rigismusiccity.de/rmctool/rmcstatustool.php');
    Finally s.savetofile('C:\temp.txt');
    End;

scheint bei mir zu funktionieren (Frag mich nich wieso zum Teufel "SaveToFile" -.-).
Ich hab an dem Programm schon ewig nicht mehr weitergearbeitet... Aber ich weis dass bevor es nen Serverwechsel gab, der Code prima geklappt hat...

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
JayEff Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Sa 10.02.07 19:44 
Also ich hab diesen Thread mal wieder ausgegraben, weil .. weis nicht wieso, aber der Code funktioniert.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
    Try
        If IdHTTP1.Connected Then
            IdHTTP1.disconnect();
        s.text := IdHTTP1.Get('http://rigismusiccity.de/rmctool/rmcstatustool.php');
    Finally s.savetofile('C:\temp.txt');
    End;

Diesen meinte ich. Klappt einfach, weis nicht warum der vorher nicht geklappt hat.
Nur falls jemand dieses Problem auch mal hat.

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.