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], '"', '"');
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], '"', '"');
end;
end;
end.