- Get link
- X
- Other Apps
Parse YouTube XML with FPC.
Compiler : Free Pascal Compiler version 3.2.0-beta-r43036 [2019/10/03] for x86_64Channel : CelibateScorpionGoingHerOwnWay cwgtow/gggtow
Feed : https://www.youtube.com/feeds/videos.xml?channel_id=UCJB9m38_DRw9KWzmErwZGZg
program CelibateScorpion;
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes, XMLRead, DOM, FPHTTPClient, OpenSSLSockets;
var
Doc: TXMLDocument;
EntryNode, TitleNode, VideoIdNode, PublishedNode : TDOMNode;
HTTPClient : TFPHTTPClient;
XMLFile : ANSIString;
Feed : TStringStream;
begin
{ Create HTTP client to fetch YT channel xml feed. }
HTTPClient := TfpHTTPClient.Create(nil);
XMLFile := HTTPClient.Get('https://www.youtube.com/feeds/videos.xml?channel_id=UCJB9m38_DRw9KWzmErwZGZg');
{ Create and store XML data in TStringStream. Accesible by ReadXMLFile }
Feed := TStringStream.Create(XMLFile);
{ Read our XML data from our TStringStream into Doc }
ReadXMLFile(Doc, Feed);
EntryNode := Doc.DocumentElement.FindNode('entry');
while Assigned(EntryNode) do
begin
TitleNode := EntryNode.FindNode('title');
VideoIdNode := EntryNode.FindNode('yt:videoId');
PublishedNode := EntryNode.FindNode('published');
WriteLn('----------------------------------------------------------------------------');
WriteLn(TitleNode.TextContent);
WriteLn('https://www.youtube.com/watch?v=' + VideoIdNode.TextContent);
WriteLn('Published : ' + PublishedNode.TextContent);
EntryNode := EntryNode.NextSibling;
end;
{ Free }
EntryNode.Free;
HTTPClient.Free;
Feed.Free;
end.
Comments
Post a Comment