root/trunk/install/php/folcast.php

リビジョン 111, 5.3 kB (コミッタ: sorshi, コミット時期: 14 年 前)

・放送波からのEPG番組表取得に対応。
・foltia_epgテーブル構成変更
・folcast.phpがSQLiteでまったく動作していなかったのを修正

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 header('Content-Disposition: attachment; filename="folcast.xml"');
23
24 include("./foltialib.php");
25 $con = m_connect();
26 /*
27 if ($useenvironmentpolicy == 1){
28     if (!isset($_SERVER['PHP_AUTH_USER'])) {
29         header("WWW-Authenticate: Basic realm=\"foltia\"");
30         header("HTTP/1.0 401 Unauthorized");
31         redirectlogin();
32         exit;
33     } else {
34     login($con,$_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']);
35     }
36 }//end if login
37 */
38 $now = date("YmdHi");   
39 $nowrfc822 date("r");
40
41 $max = getgetnumform(max);
42
43 if ($max > 0 ){
44     //件数指定があればなにもしない
45 }else{
46     $max = 45;
47 }
48 $tid = getgetnumform(tid);
49 if (($tid >= 0 ) && ($tid != "")){
50
51 $query = "
52 SELECT  foltia_program.tid,foltia_program.title,
53 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\" LIKE 'M%%'  AND foltia_program.tid = foltia_subtitle.tid AND foltia_program.tid = $tid   
54 ORDER BY enddatetime DESC
55  limit ? offset 0
56 ";
57
58 $titlequery = "
59 SELECT  foltia_program.tid,foltia_program.title
60 FROM  foltia_program   
61 WHERE foltia_program.tid = ?   
62 ";
63 //    $titlers = m_query($con, $query, "DBクエリに失敗しました");
64     $titlers = sql_query($con, $query, "DBクエリに失敗しました",array($tid));
65 //    $titlers = sql_query($con, $titlequery, "DBクエリに失敗しました",array($tid));
66     $rowdata = $titlers->fetch();
67     $rsstitle = $rowdata[1];
68 }else{
69
70 $query = "
71 SELECT  foltia_program.tid,foltia_program.title,
72 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\" LIKE 'M%%'  AND foltia_program.tid = foltia_subtitle.tid ORDER BY enddatetime DESC
73 limit  ? offset 0
74     ";
75
76
77
78     $rsstitle = "新規録画";
79 }//if
80
81 $header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
82 <rss xmlns:itunes=\"http://www.itunes.com/DTDs/Podcast-1.0.dtd\" version=\"2.0\">
83     <channel>
84         <title>$rsstitle:Folcast</title>
85         <itunes:author>DCC-JPL Japan/foltia project</itunes:author>
86         <link>http://www.dcc-jpl.com/soft/foltia/</link>
87         <description>フォルティアが未読処理をお助けしちゃいます</description>
88         <itunes:subtitle>foltia video podcast :$rsstitle:Folcast</itunes:subtitle>
89         <itunes:summary>フォルティアが未読処理をお助けしちゃいます</itunes:summary>
90         <language>ja</language>
91         <copyright>foltia</copyright>
92         <itunes:owner>
93             <itunes:name>$rsstitle:Folcast</itunes:name>
94             <itunes:email>foltia@dcc-jpl.com</itunes:email>
95         </itunes:owner>         
96         <category>Technology</category>
97         <itunes:category text=\"Technology\"></itunes:category>
98
99 ";
100 $header = mb_convert_encoding($header,"UTF-8", "EUC-JP");
101 print $header;
102
103 //    $rs = m_query($con, $query, "DBクエリに失敗しました");
104     $rs = sql_query($con, $query, "DBクエリに失敗しました",array($max));
105 $rowdata = $rs->fetch();
106
107 if (! $rowdata) {
108                 //die_exit("No items");   
109 }else{
110     do {
111 //$title = mb_convert_encoding($rowdata[1],"UTF-8", "EUC-JP");
112 $tid $rowdata[0];
113 $title = $rowdata[1];
114 $title = htmlspecialchars($title);
115 $countno = $rowdata[2];
116 if ($countno > 0 ){
117     $countprint = "第".$countno."回";
118 }else{
119     $countprint="";
120 }
121 $subtitle = $rowdata[3];
122 $subtitle = htmlspecialchars($subtitle);
123 $onairdate = $rowdata[4];
124 $day = substr($onairdate,0,4)."/".substr($onairdate,4,2)."/".substr($onairdate,6,2);
125 $time = substr($onairdate,8,2).":".substr($onairdate,10,2);
126 $onairdate = "$day $time";
127
128 $starttimerfc822 = foldate2rfc822($rowdata[4]);
129
130 $mp4filename = $rowdata[5];
131 $mp4uri = "http://". getserverfqdn()  .$httpmediamappath ."/$tid.localized/mp4/$mp4filename";
132 $mp4thmname = $rowdata[5];
133 $mp4thmname = ereg_replace(".MP4", ".THM", $mp4thmname);
134 $mp4thmnameuri = "http://". getserverfqdn() . $httpmediamappath ."/$tid.localized/mp4/$mp4thmname";
135
136 if (file_exists("$recfolderpath/$tid.localized/mp4/$mp4filename")) {
137     $mp4filestat = stat("$recfolderpath/$tid.localized/mp4/$mp4filename");
138     $mp4filesize = $mp4filestat[7];
139 } else {
140     $mp4filesize = 0;
141 }
142
143 if ($rowdata[0] == 0 ){//EPG録画
144     $showntitle = "$title $subtitle";
145 }else{
146     $showntitle = "$title $countprint";
147 }
148
149
150 $item ="    <item>
151           <title>$showntitle</title>
152           <itunes:author>foltia</itunes:author>
153           <description>$title $countprint $subtitle</description>
154           <itunes:subtitle>$title $countprint $subtitle</itunes:subtitle>
155           <itunes:summary>$title $countprint $subtitle</itunes:summary>
156           <enclosure url=\"$mp4uri\" length=\"$mp4filesize\" type=\"video/mov\" />
157           <guid isPermaLink=\"true\">$mp4thmnameuri</guid>
158           <pubDate>$starttimerfc822</pubDate>
159           <itunes:explicit>no</itunes:explicit>
160           <itunes:keywords>foltia,Folcast,DCC-JPL Japan,$title,$subtitle</itunes:keywords> 
161           <itunes:image href=\"$mp4thmnameuri\" />
162         </item>
163 ";
164
165 $item = mb_convert_encoding($item,"UTF-8", "EUC-JP");
166 print $item ;
167
168     } while ($rowdata = $rs->fetch()); //do
169
170 }//if
171         ?>
172    
173     </channel>
174 </rss>
175
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。
track feed