root/trunk/install/php/folcast.php

リビジョン 1, 4.7 kB (コミッタ: jplcom, コミット時期: 18 年 前)

initial import

Line 
1 <?php
2 /*
3  Anime recording system foltia
4  http://www.dcc-jpl.com/soft/foltia/
5
6 folcast.php
7
8 目的
9 foltia video podcast(folcast)用RSSを出力します。
10
11 オプション
12 tid:タイトルID
13  省略時は新規録画全部
14 max:表示上限
15  省略時は45件
16
17  DCC-JPL Japan/foltia project
18
19 */
20
21 header('Content-Type: application/rss+xml');
22
23
24   include("./foltialib.php");
25 $con = m_connect();
26
27 $now = date("YmdHi");   
28 $nowrfc822 date("r");
29
30 $max = getgetnumform(max);
31
32 if ($max > 0 ){
33     //件数指定があればなにもしない
34 }else{
35     $max = 45;
36 }
37 $tid = getgetnumform(tid);
38 if (($tid >= 0 ) && ($tid != "")){
39
40 $query = "
41 SELECT  foltia_program.tid,foltia_program.title,
42 foltia_subtitle.countno , foltia_subtitle.subtitle , foltia_subtitle.startdatetime, foltia_subtitle.pspfilename,foltia_subtitle.lengthmin,foltia_subtitle.enddatetime   FROM foltia_subtitle , foltia_program   WHERE \"pspfilename\" ~~ 'M4V%%'  AND foltia_program.tid = foltia_subtitle.tid AND foltia_program.tid = $tid   
43 ORDER BY \"enddatetime\" DESC
44 offset 0 limit  $max
45     ";
46
47 $titlequery = "
48 SELECT  foltia_program.tid,foltia_program.title
49 FROM  foltia_program   
50 WHERE foltia_program.tid = $tid   
51 ";
52     $titlers = m_query($con, $query, "DBクエリに失敗しました");
53     $rowdata = pg_fetch_row($titlers, 0);
54     $rsstitle = $rowdata[1];
55 }else{
56
57 $query = "
58 SELECT  foltia_program.tid,foltia_program.title,
59 foltia_subtitle.countno , foltia_subtitle.subtitle , foltia_subtitle.startdatetime, foltia_subtitle.pspfilename,foltia_subtitle.lengthmin,foltia_subtitle.enddatetime   FROM foltia_subtitle , foltia_program   WHERE \"pspfilename\" ~~ 'M4V%%'  AND foltia_program.tid = foltia_subtitle.tid ORDER BY \"enddatetime\" DESC
60 offset 0 limit  $max
61     ";
62     $rsstitle = "新規録画";
63 }//if
64
65 $header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
66 <rss xmlns:itunes=\"http://www.itunes.com/DTDs/Podcast-1.0.dtd\" version=\"2.0\">
67     <channel>
68         <title>Folcast ($rsstitle)</title>
69         <itunes:author>DCC-JPL Japan/foltia project</itunes:author>
70         <link>http://www.dcc-jpl.com/soft/foltia/</link>
71         <description>フォルティアが未読処理をお助けしちゃいます</description>
72         <itunes:subtitle>foltia video podcast :Folcast ($rsstitle)</itunes:subtitle>
73         <itunes:summary>フォルティアが未読処理をお助けしちゃいます</itunes:summary>
74         <language>ja</language>
75         <copyright>foltia</copyright>
76         <itunes:owner>
77             <itunes:name>Folcast ($rsstitle)</itunes:name>
78             <itunes:email>foltia@dcc-jpl.com</itunes:email>
79         </itunes:owner>         
80         <category>Technology</category>
81         <itunes:category text=\"Technology\"></itunes:category>
82
83 ";
84 $header = mb_convert_encoding($header,"UTF-8", "EUC-JP");
85 print $header;
86
87     $rs = m_query($con, $query, "DBクエリに失敗しました");
88     $maxrows = pg_num_rows($rs);
89
90 if ($maxrows == 0) {
91                 //die_exit("No items");   
92 }else{
93
94 for ($row = 0; $row < $maxrows; $row++) {
95         $rowdata = pg_fetch_row($rs, $row);
96         
97 //$title = mb_convert_encoding($rowdata[1],"UTF-8", "EUC-JP");
98 $tid $rowdata[0];
99 $title = $rowdata[1];
100 $title = htmlspecialchars($title);
101 $countno = $rowdata[2];
102 if ($countno > 0 ){
103     $countprint = "第".$countno."回";
104 }else{
105     $countprint="";
106 }
107 $subtitle = $rowdata[3];
108 $subtitle = htmlspecialchars($subtitle);
109 $onairdate = $rowdata[4];
110 $day = substr($onairdate,0,4)."/".substr($onairdate,4,2)."/".substr($onairdate,6,2);
111 $time = substr($onairdate,8,2).":".substr($onairdate,10,2);
112 $onairdate = "$day $time";
113
114 $starttimerfc822 = foldate2rfc822($rowdata[4]);
115
116 $mp4filename = $rowdata[5];
117 $mp4uri = "http://". getserverfqdn()  .$httpmediamappath ."/$tid.localized/mp4/$mp4filename";
118 $mp4thmname = $rowdata[5];
119 $mp4thmname = ereg_replace(".MP4", ".THM", $mp4thmname);
120 $mp4thmnameuri = "http://". getserverfqdn() . $httpmediamappath ."/$tid.localized/mp4/$mp4thmname";
121 $mp4filestat = stat("$recfolderpath/$tid.localized/mp4/$mp4filename");
122 $mp4filesize = $mp4filestat[7];
123
124 if ($rowdata[0] == 0 ){//EPG録画
125     $showntitle = "$title $subtitle";
126 }else{
127     $showntitle = "$title $countprint";
128 }
129
130
131 $item ="    <item>
132           <title>$showntitle</title>
133           <itunes:author>foltia</itunes:author>
134           <description>$title $countprint $subtitle</description>
135           <itunes:subtitle>$title $countprint $subtitle</itunes:subtitle>
136           <itunes:summary>$title $countprint $subtitle</itunes:summary>
137           <enclosure url=\"$mp4uri\" length=\"$mp4filesize\" type=\"video/mov\" />
138           <guid isPermaLink=\"true\">$mp4thmnameuri</guid>
139           <pubDate>$starttimerfc822</pubDate>
140           <itunes:explicit>no</itunes:explicit>
141           <itunes:keywords>foltia,Folcast,DCC-JPL Japan,$title,$subtitle</itunes:keywords> 
142           <itunes:image href=\"$mp4thmnameuri\" />
143         </item>
144 ";
145
146 $item = mb_convert_encoding($item,"UTF-8", "EUC-JP");
147 print $item ;
148
149 }//for
150
151 }//if
152         ?>
153    
154     </channel>
155 </rss>
156
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。
track feed