unit VideoModule interface uses Windows Messages SysUtils Variants Cla

  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
unit VideoModule;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, RegExpr, httpsend, OleCtrls, SHDocVw, ExtCtrls;
type
TForm1 = class(TForm)
ParsList: TListBox;
WebBrowser1: TWebBrowser;
Timer1: TTimer;
function Replace(Str, X, Y: string): string;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
HTTP: THTTPSend;
str, prx2, prx3: tstringlist;
reg2, reg3: tregexpr;
a,i: Integer;
begin
HTTP:= tHTTPSend.Create;
str:= tstringlist.Create;
HTTP.HTTPMethod('GET','http://www.youtube.com/user/EscadaSET/videos');
str.LoadFromStream(HTTP.Document);
prx3:=TStringList.Create;
//ParsList.Lines.Add(str.Text) ;
prx2:=TStringList.Create;
reg3:= tregexpr.Create;
reg3.Expression:= 'data-button-menu-id=\"shared-addto-watch-later-login\" data-video-ids=\"(.*?)\"\><span class=\"yt-uix-button-content\">';
if reg3.Exec(utf8toansi(str.Text)) then repeat
prx2.Add(reg3.Match[1]);
until
not
reg3.ExecNext;
reg2:= tregexpr.Create;
reg2.Expression:= '<h3 class=\"yt-lockup-title\"><a class=\"yt-uix-sessionlink yt-uix-tile-link spf-link yt-ui-ellipsis yt-ui-ellipsis-2\" dir=\"ltr\" title=\"(.*?)\" data-sessionlink=';
if reg2.Exec(utf8toansi(str.Text)) then repeat
prx3.Add(reg2.Match[1]);
until
not
reg2.ExecNext;
for I := 0 to prx2.Count-1 do
begin
ParsList.Items.Add(prx3.Strings[I] + ' (ID: ' + prx2.Strings[I] + ')');
end;
for a := 0 to ParsList.Items.Count-1 do
ParsList.Items[a] := Replace(ParsList.Items[a], '&quot;', '"');
end;
function TForm1.Replace(Str, X, Y: string): string;
var
buf1, buf2, buffer: string;
i: Integer;
begin
buf1 := '';
buf2 := Str;
Buffer := Str;
while Pos(X, buf2) > 0 do
begin
buf2 := Copy(buf2, Pos(X, buf2), (Length(buf2) - Pos(X, buf2)) + 1);
buf1 := Copy(Buffer, 1, Length(Buffer) - Length(buf2)) + Y;
Delete(buf2, Pos(X, buf2), Length(X));
Buffer := buf1 + buf2;
end;
Replace := Buffer;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
HTTP: THTTPSend;
str, prx2, prx3: tstringlist;
reg2, reg3: tregexpr;
a,i: Integer;
begin
if ParsList.Items.Text='' then begin
HTTP:= tHTTPSend.Create;
str:= tstringlist.Create;
HTTP.HTTPMethod('GET','http://www.youtube.com/user/EscadaSET/videos');
str.LoadFromStream(HTTP.Document);
prx3:=TStringList.Create;
//ParsList.Lines.Add(str.Text) ;
prx2:=TStringList.Create;
reg3:= tregexpr.Create;
reg3.Expression:= 'data-button-menu-id=\"shared-addto-watch-later-login\" data-video-ids=\"(.*?)\"\><span class=\"yt-uix-button-content\">';
if reg3.Exec(utf8toansi(str.Text)) then repeat
prx2.Add(reg3.Match[1]);
until
not
reg3.ExecNext;
reg2:= tregexpr.Create;
reg2.Expression:= '<h3 class=\"yt-lockup-title\"><a class=\"yt-uix-sessionlink yt-uix-tile-link spf-link yt-ui-ellipsis yt-ui-ellipsis-2\" dir=\"ltr\" title=\"(.*?)\" data-sessionlink=';
if reg2.Exec(utf8toansi(str.Text)) then repeat
prx3.Add(reg2.Match[1]);
until
not
reg2.ExecNext;
for I := 0 to prx2.Count-1 do
begin
ParsList.Items.Add(prx3.Strings[I] + ' (ID: ' + prx2.Strings[I] + ')');
end;
for a := 0 to ParsList.Items.Count-1 do
ParsList.Items[a] := Replace(ParsList.Items[a], '&quot;', '"');
end;
end;
end.