FAQ  •  Register  •  Login

RSS Generator for files on a Webserver

<<

stit

Serviio newbie

Posts: 6

Joined: Thu Nov 22, 2012 8:35 pm

Post Mon Nov 26, 2012 7:52 pm

RSS Generator for files on a Webserver

Hi all,

i wrote a php script which scans for files on a webserver and makes them available as RSS feed.
So files on webserver can be streamed to the TV over http via "Atom/RSS" section at serviio.

  Code:
<?php
   header("Content-type: text/xml");
   echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>";
?>
<rss version="2.0">
<channel>
    <title>Title</title>
    <link>http://www.domain.com</link>
    <description>Description</description>
    <language>de-de</language>
    <lastBuildDate><?php $now = time(); echo date(r, $now); ?></lastBuildDate>
    <image>
      <title>Title</title>
      <url></url>
      <link></link>
    </image>
<?php
function ListFiles($dir)
{
    if($dh = opendir($dir))
   {
        $files = Array();
        $inner_files = Array();

        while($file = readdir($dh))
      {
            if($file != "." && $file != ".." && $file[0] != '.')
         {
                if(is_dir($dir . "/" . $file))
            {
                    $inner_files = ListFiles($dir . "/" . $file);
                    if(is_array($inner_files)) $files = array_merge($files, $inner_files);
                }
            else
            {
               $directLink = str_replace("/var/www/files", "http://www.domain.com/nameOfDirOnServer", $dir);
               array_push($files, $directLink ."/". $file);
                }
            }
        }
        closedir($dh);
        return $files;
    }
}
$fileLinks = ListFiles('/var/www/files');
foreach($fileLinks as $url) {
   if(preg_match("/.(avi|mkv|mp4)/",$url))
   {
      $filename = basename($url);
      $dirname = basename(dirname($url));
      $filesize = filesize("/var/www/files/".$dirname."/".$filename);
?>
    <item>
    <title><?php echo $filename; ?></title>
    <link><?php echo $url; ?></link>
    <guid><?php echo $url; ?></guid>
    <description><?php echo $filename; ?></description>
    <pubDate></pubDate>
   <enclosure url="<?php echo $url; ?>" length="<?php echo $filesize; ?>" type="video/mp4" />
    </item>
<?php
   }
}
?>
</channel>
</rss>


If someone knows how to make RSS feed available with .htacces security instead of public webpages, please tell me.
I tried http://user:password@www.domain.com/files/rss.php but serviio doesnt show up the files.

Thanks.
stit
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17212

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Mon Nov 26, 2012 10:29 pm

Re: RSS Generator for files on a Webserver

stit wrote:I tried http://user:password@www.domain.com/files/rss.php but serviio doesnt show up the files.

It should work. Does it work in a browser?
<<

stit

Serviio newbie

Posts: 6

Joined: Thu Nov 22, 2012 8:35 pm

Post Wed Nov 28, 2012 9:17 pm

Re: RSS Generator for files on a Webserver

Yes in the Browser everything works.
But on the TV the Folder with the name of my RSS Entry won't show up.

If i make the .php file public available without the username:passwort@ it works.
But this is no option for me as i don't want to make my files public available :(.

Hopefully this .htaccess support will be implemented ??
Or what am i doing wrong?

Thanks.
stit
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17212

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Wed Nov 28, 2012 9:43 pm

Re: RSS Generator for files on a Webserver

If the server supports HTTP Basic authentication then it should work. Not sure what .httpaccess does.
<<

stit

Serviio newbie

Posts: 6

Joined: Thu Nov 22, 2012 8:35 pm

Post Sat Dec 01, 2012 10:15 pm

Re: RSS Generator for files on a Webserver

This is the .htaccess i am using.
The type of authentication is Basic, so basic authentication should be enabled.

  Code:
Options +Indexes
AuthName Login
AuthType Basic
AuthUserFile /var/.htpasswd
require user admin


What can i do for debugging ? Checking if serviio is receiving the feed correctly?

Thanks
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17212

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Sat Dec 01, 2012 10:27 pm

Re: RSS Generator for files on a Webserver

try to enable detailed log
<<

stit

Serviio newbie

Posts: 6

Joined: Thu Nov 22, 2012 8:35 pm

Post Tue Dec 04, 2012 9:51 pm

Re: RSS Generator for files on a Webserver

Or maybe this is the problem?

DEBUGInfo:
2012-12-04 23:00:13,796 WARN [FeedUpdaterThread] Failed to retrieve online item information for http://www.url.com/dlna/Tiger.avi. It might not play.
java.io.IOException: org.serviio.library.local.metadata.extractor.InvalidMediaFormatException: Unknown video file type.
at org.serviio.library.online.metadata.FeedUpdaterThread.retrieveMetadata(FeedUpdaterThread.java:291)
at org.serviio.library.online.metadata.FeedUpdaterThread.retrieveTechnicalMetadata(FeedUpdaterThread.java:209)
at org.serviio.library.online.metadata.FeedUpdaterThread.run(FeedUpdaterThread.java:102)
Caused by: org.serviio.library.local.metadata.extractor.InvalidMediaFormatException: Unknown video file type.
at org.serviio.library.metadata.FFmpegMetadataRetriever.validateCodecsFound(FFmpegMetadataRetriever.java:382)
at org.serviio.library.metadata.FFmpegMetadataRetriever.retrieveMetadata(FFmpegMetadataRetriever.java:86)
at org.serviio.library.metadata.FFmpegMetadataRetriever.retrieveOnlineMetadata(FFmpegMetadataRetriever.java:124)
at org.serviio.library.online.metadata.FeedUpdaterThread.retrieveMetadata(FeedUpdaterThread.java:268)
... 2 more

Can this filecheck be disabled somehow? Because my tv plays nearly all files and a check is not needed.
Or can i enable serviio to show the files even though the link is not working?
Because the links are only working if i copy the files to the public directory, but the rss feed is generated from a not public directory. I make this to secure my files, and copy them only temporary to the public directory to play them. Because .htacces is not working at the moment.

Thanks.
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17212

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Tue Dec 04, 2012 11:16 pm

Re: RSS Generator for files on a Webserver

this check is mandatory

Return to Plugin development

Who is online

Users browsing this forum: No registered users and 22 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.