Autor Beitrag
Delphi2009lover
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 176



BeitragVerfasst: Do 19.11.09 07:46 
Hi,

wenn ich diesen Code hier benutze:

VIDEO_TITLE := Copy(Quelltext, Pos('''VIDEO_TITLE'':',Quelltext) + 14, PosEx(''',', Quelltext, Pos('''VIDEO_TITLE'':',Quelltext) + 13) - Pos('''VIDEO_TITLE'':',Quelltext)+13);

bekomme ich das: '太鼓の達人7代目 きたさいたま2000',

'SWF_URL': (yt.flash

in meiner Textbox angezeigt. Ish glaub zwar eher, dass das ein Programmierfehler ist, aber trotzdem: es wurde mit Delphi 2010 geschrieben(orginal ;-))
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Do 19.11.09 07:54 
Sieht für mich erstmal wie ein AnsiString/UnicodeString-Problem aus. :nixweiss:

_________________
We are, we were and will not be.
Delphi2009lover Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 176



BeitragVerfasst: Do 19.11.09 08:03 
Nein nein!! Das Video heißt so: 太鼓の達人7代目 きたさいたま2000

nur ließt er zu viel aus. (Der Quelltext ist natürlich der der Youtube-Seite mit dem Video^^
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Do 19.11.09 10:36 
OK, aber ich bleibe bei meiner Vermutung. ;-)

Ich denke, dass da mit den Längen, die du bei Copy verwendest irgendwas bzgl. Zeichenzahl und Bytezahl durcheinander kommt.

_________________
We are, we were and will not be.
Andreas L.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: Do 19.11.09 10:44 
Welchen Typ haben die Variablen VIDEO_TITLE und Quelltext?
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Do 19.11.09 14:07 
ich habs mal etwas zusammengekürzt:

ausblenden Delphi-Quelltext
1:
2:
  qindex := Pos('''VIDEO_TITLE'':',Quelltext) + 13;
  VIDEO_TITLE := Copy(Quelltext, qindex + 1, PosEx(''',', Quelltext, qindex) - qindex);


Sogesehen, stimmt eigentlich alles. Gausi dürfte wohl recht haben.

lg elundril

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
Delphi2009lover Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 176



BeitragVerfasst: Do 19.11.09 15:49 
Ok ihr hattet wohl doch Recht. Ich hatte Quelltext: String; aber ich weiß warum ich es nicht zu Widestring gemacht hab: Da kommen folgende Fehler:

Diese Funktion soll überprüfen, ob in dem Quelltext 'IS_HD_AVIABLE' enthalten ist wenn ja sagt er, das der URL ok ist:

ausblenden Delphi-Quelltext
1:
If Pos('''IS_HD_AVAILABLE''', Quelltext) <> 0 Then URLOK := True;					


Fehler:
[DCC Fehler] Main.pas(231): E2251 Doppeldeutiger überladener Aufruf von 'Pos'
System.pas(16695): Verwandte Methode: function Pos(const WideString; const WideString): Integer;
System.pas(18386): Verwandte Methode: function Pos(const string; const string): Integer;

[DCC Warnung] Main.pas(231): W1058 Implizite String-Umwandlung mit potenziellem Datenverlust von 'WideString' zu 'RawByteString'


genau so sieht es auch bei allen anderen Abfragen aus, die mit Pos die Stelle eines Wortes abfragen^^
SAiBOT
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 323
Erhaltene Danke: 6

XP SP2; 7
D7; D2009
BeitragVerfasst: Do 19.11.09 16:42 
In D2010 ist für deine Zwecke String der richtige Typ.
Du solltest nur nicht am Ende bei "'" schneiden sondern bei #13#10 (Zeilenumbruch) und zurückrechen.
Ansonsten kann es passieren, falls der Titel schon ein "'" enthält, das an dieser Stelle geschnitten wird!
Ansosnten schicke doch mal den Videolink oder zumindest die passende Codestelle und dir kann geholfen werden.

_________________
Debuggers don't remove bugs, they only show them in slow-motion.
Delphi2009lover Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 176



BeitragVerfasst: Do 19.11.09 17:19 
Hey danke erstmal, aber das mit dem Zeienumbruch bekomme ich überhaupt nicht hin... kannst du das vllt in den Code oben einfügen?
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Do 19.11.09 17:23 
ausblenden Delphi-Quelltext
1:
2:
  qindex := Pos('''VIDEO_TITLE'':',Quelltext) + 13;
  VIDEO_TITLE := Copy(Quelltext, qindex + 1, PosEx(#10#13, Quelltext, qindex) - qindex);


Voilá ;) War doch ned mal so schwer. :D

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
SAiBOT
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 323
Erhaltene Danke: 6

XP SP2; 7
D7; D2009
BeitragVerfasst: Do 19.11.09 19:54 
www.delphi-forum.de/...p;highlight=getpiece

=>

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:
function GetPiece(Source, Praefix, Suffix: String):String;
var
  pos1,restc,resc: Integer;
  rest:String;
begin
  if Praefix = #00 then
    pos1 := 0
  else
    pos1  := Pos(Praefix, Source)+Length(Praefix);
  restc := Length(Source)-Pos1+1;
  rest  := Copy(Source, pos1, restc);
  resc  := Pos(Suffix, rest);
  if resc = 0 then
    Result := rest
  else
    Result := Copy(rest, 0, resc-1);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  Titel,Code: String;
begin
  Code := http.Get('http://www.youtube.com/watch?v=C1PcU8XpeuQ&feature=response_watch');
  Titel := GetPiece(Code,'''VIDEO_TITLE'': ''', #10#10);
  if (Length(Titel) >= 3) then
  begin
    Titel := Copy(Titel, 1, Length(Titel)-2); // entfernen von -> ',
    ShowMessage('Titel gefunden: "'+Titel+'"');
  end
  else
    ShowMessage('Titel nicht gefunden!');
end;


Das sollte jetzt aber Erklärung genug sein!

_________________
Debuggers don't remove bugs, they only show them in slow-motion.