1 | unit PageTV;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, FileUtil, WebPage, HTTPServer, SqlDatabase, HtmlClasses,
|
---|
7 | Utils, ModuleUser;
|
---|
8 |
|
---|
9 | type
|
---|
10 |
|
---|
11 | { TWebPageTV }
|
---|
12 |
|
---|
13 | TWebPageTV = class(TWebPage)
|
---|
14 | procedure DataModuleProduce(HandlerData: THTTPHandlerData);
|
---|
15 | private
|
---|
16 | procedure HandleList(HandlerData: THTTPHandlerData);
|
---|
17 | procedure HandlePlaylist(HandlerData: THTTPHandlerData);
|
---|
18 | public
|
---|
19 | ModuleUser: TModuleUser;
|
---|
20 | end;
|
---|
21 |
|
---|
22 | var
|
---|
23 | WebPageTV: TWebPageTV;
|
---|
24 |
|
---|
25 |
|
---|
26 | implementation
|
---|
27 |
|
---|
28 | {$R *.lfm}
|
---|
29 |
|
---|
30 | uses
|
---|
31 | Core, WebSession;
|
---|
32 |
|
---|
33 | { TWebPageTV }
|
---|
34 |
|
---|
35 | procedure TWebPageTV.DataModuleProduce(HandlerData: THTTPHandlerData);
|
---|
36 | var
|
---|
37 | PageName: string;
|
---|
38 | begin
|
---|
39 | with TWebSession(HandlerData) do begin
|
---|
40 | if Request.Path.Count > 1 then PageName := Request.Path[1]
|
---|
41 | else PageName := '';
|
---|
42 | with HtmlDocument.Body do begin
|
---|
43 | if PageName = '' then PageName := 'list';
|
---|
44 | if PageName = 'list' then HandleList(HandlerData)
|
---|
45 | else if PageName = 'playlist' then HandlePlaylist(HandlerData);
|
---|
46 | end;
|
---|
47 | end;
|
---|
48 | end;
|
---|
49 |
|
---|
50 | procedure TWebPageTV.HandleList(HandlerData: THTTPHandlerData);
|
---|
51 | var
|
---|
52 | I: Integer;
|
---|
53 | DbRows: TDbRows;
|
---|
54 | TuneUp: string;
|
---|
55 | begin
|
---|
56 | with TWebSession(HandlerData) do begin
|
---|
57 | ModuleUser.LoadUserInfo;
|
---|
58 | with HtmlDocument.Body, SubItems.AddString do begin
|
---|
59 | Text := 'Stažení přehrávače: <a href="http://www.videolan.org/vlc/">VLC Media Player</a><br/>' +
|
---|
60 | 'Seznam všech kanálů do přehrávače: <a href="playlist/">Playlist</a><br/>' +
|
---|
61 | 'Zobrazení playlistu ve VLC lze provést pomocí menu <strong>View - Playlist</strong> nebo klávesové zkratky CTRL+L<br/>' +
|
---|
62 | '<br/>' +
|
---|
63 | '<div align="center"><strong>Výpis kanálů:</strong><br>';
|
---|
64 | Text := Text + '<table class="WideTable">' +
|
---|
65 | '<tr><th>Název</th><th>Jazyk</th><th>Kategorie</th><th>Ladění</th></tr>';
|
---|
66 | try
|
---|
67 | DbRows := TDbRows.Create;
|
---|
68 | Database.Query(DbRows, 'SELECT * FROM `TV` WHERE (`Stream` <> "") OR (`StreamWeb` <> "") ORDER BY `Name` DESC');
|
---|
69 | for I := 0 to DbRows.Count - 1 do
|
---|
70 | with DbRows[I] do begin
|
---|
71 | TuneUp := ' ';
|
---|
72 | if Items['StreamWeb'] <> '' then
|
---|
73 | TuneUp := MakeLink('Naladit', Items['StreamWeb']);
|
---|
74 | if Items['Stream'] <> '' then
|
---|
75 | TuneUp := MakeLink('Naladit', NavigationLink('/tv/playlist?id=' + Items['ShortName']));
|
---|
76 | Text := Text + '<tr><td>' + MakeLink(Items['Name'], Items['Homepage']) +
|
---|
77 | '</td><td align="center">' +
|
---|
78 | Items['Language'] + '</td><td align="center">' + Items['Category'] + '</td>' +
|
---|
79 | '<td>' + TuneUp + '</td></tr>';
|
---|
80 | end;
|
---|
81 | Text := Text + '</table></div><br/>';
|
---|
82 |
|
---|
83 | Text := Text + 'Originální informace o televizi: <a href="http://tv.hovnet.czf/">HovNet televize</a><br/>';
|
---|
84 | Text := Text + 'Další online TV na webu: <a href="http://spustit.cz">Spustit.cz</a><br/>';
|
---|
85 | Text := Text + 'Další online TV na webu: <a href="http://www.tvinfo.cz/live/televize/evropa/cz">TV info</a><br/>';
|
---|
86 |
|
---|
87 | finally
|
---|
88 | DbRows.Free;
|
---|
89 | end;
|
---|
90 | Text := Text + '</table>';
|
---|
91 | end;
|
---|
92 | GeneratePage(Self);
|
---|
93 | end;
|
---|
94 | end;
|
---|
95 |
|
---|
96 | procedure TWebPageTV.HandlePlaylist(HandlerData: THTTPHandlerData);
|
---|
97 | var
|
---|
98 | DbRows: TDbRows;
|
---|
99 | I: Integer;
|
---|
100 | Text: string;
|
---|
101 | Id: string;
|
---|
102 | begin
|
---|
103 | with TWebSession(HandlerData) do begin
|
---|
104 | Response.Headers.Add('Content-Type', 'audio/mpegurl');
|
---|
105 | Response.Headers.Add('Content-Disposition', 'attachment; filename=playlist.m3u');
|
---|
106 | try
|
---|
107 | DbRows := TDbRows.Create;
|
---|
108 |
|
---|
109 | Text := '#EXTM3U' + LineEnding;
|
---|
110 | if Request.Query.TryGetValue('id', Id) then begin
|
---|
111 | Database.Select(DbRows, 'TV', '*', ' (`Stream` <> "") AND (`ShortName`="' + Database.EscapeString(Id) + '") ');
|
---|
112 | if DbRows.Count > 0 then begin
|
---|
113 | Text := Text + '#EXTINF:0,' + DbRows[0].Items['Name'] + LineEnding
|
---|
114 | + DbRows[0].Items['Stream'] + LineEnding;
|
---|
115 | end;
|
---|
116 | end else begin
|
---|
117 | Database.Select(DbRows, 'TV', '*', ' (`Stream` <> "") ORDER BY `Name` ');
|
---|
118 | for I := 0 to DbRows.Count - 1 do begin
|
---|
119 | Text := Text + '#EXTINF:0,' + DbRows[I].Items['Name'] + LineEnding
|
---|
120 | + DbRows[I].Items['Stream'] + LineEnding;
|
---|
121 | end;
|
---|
122 | end;
|
---|
123 | Response.Content.WriteString(Text);
|
---|
124 |
|
---|
125 | finally
|
---|
126 | DbRows.Free;
|
---|
127 | end
|
---|
128 | end;
|
---|
129 | end;
|
---|
130 |
|
---|
131 | end.
|
---|
132 |
|
---|