Author Topic: .m3u or rss templates for HFS (customize MIME needed)  (Read 5673 times)

0 Members and 1 Guest are viewing this topic.

Offline est

  • Occasional poster
  • *
  • Posts: 2
    • View Profile
.m3u or rss templates for HFS (customize MIME needed)
« on: July 07, 2009, 04:57:55 AM »
Hi all,

I need to share a folder in dir listing mode, as well as .m3u or rss podcast feeds,

I tried to edit the template to make the output looks like .m3u or rss, but some media player seems having a trouble parsing the MIME. Is there a way to define MIME in HFS template? Or more advanced, customize a HTTP header?

Or why not HFS provide a way of multiple views of dir listing, like

normal dir listing: http://127.0.0.1/mp3/
m3u for current dir: http://127.0.0.1/mp3/:m3u
m3u for .mp3 files only: http://127.0.0.1/mp3/:m3u?filter=*.mp3

currently I am using a mongoose+python script to do this, I really HFS could provide such a funtion directly
« Last Edit: July 07, 2009, 05:00:22 AM by est »

Offline rejetto

  • Administrator
  • Insane programmer
  • *
  • Posts: 12379
    • View Profile
Re: .m3u or rss templates for HFS (customize MIME needed)
« Reply #1 on: July 07, 2009, 05:37:43 AM »
> Is there a way to define MIME in HFS template?

switch to expert mode
menu > other options > mime types

> Or more advanced, customize a HTTP header?

in HFS 2.3 you can use command {.add header.}
refer official documentation for details

Offline est

  • Occasional poster
  • *
  • Posts: 2
    • View Profile
Re: .m3u or rss templates for HFS (customize MIME needed)
« Reply #2 on: July 07, 2009, 07:37:36 AM »
> Is there a way to define MIME in HFS template?

switch to expert mode
menu > other options > mime types

> Or more advanced, customize a HTTP header?

in HFS 2.3 you can use command {.add header.}
refer official documentation for details

thanks rejetto

place this filelist.tpl under the same dir as hfs242.exe,

Code: [Select]
#EXTM3U
%files%
[style]

[files]
{.mime|audio/x-mpegurl.}

%list%

[file]
%item-url%

[folder]
%item-name%/

http://localhost/mp3/~files.lst.m3u

works great!

Offline Mijo

  • Occasional poster
  • *
  • Posts: 2
    • View Profile
Re: .m3u or rss templates for HFS (customize MIME needed)
« Reply #3 on: October 19, 2010, 02:46:40 AM »
I made some modifications, to support both normal lists and m3u files.

I added conditional statements which recognize a new GET parameter "filetype". If it is there, and its value is "m3u", then a .m3u file is generated.

filelist.tpl
Code: [Select]
{.if|{.=|{.urlvar|filetype.}|m3u.}|#EXTM3U.}
%files%

[style]

[files]
{.if|{.=|{.urlvar|filetype.}|m3u.}|{:{.mime|audio/x-mpegurl.}:}.}
%list%

[file]
%item-url%

[folder]
%item-name%/

Then in the hfs.tpl add a line like this in the menu's div. I used it right after the normal File list.

hfs.tpl
Code: [Select]
<li class="last"><a href="{.get|url|tpl=list|filetype=m3u|folders-filter=\|recursive.}">File list (.M3U)</a></li>
Enjoy!
Mijo

Offline Mijo

  • Occasional poster
  • *
  • Posts: 2
    • View Profile
Re: .m3u or rss templates for HFS (customize MIME needed)
« Reply #4 on: December 17, 2010, 11:19:59 AM »
Other small modifications:

Code: [Select]
{.if|{.=|{.urlvar|filetype.}|m3u.}|#EXTM3U.}
%files%

[style]

[files]
{.if|{.=|{.urlvar|filetype.}|m3u.}|{:{.mime|audio/x-mpegurl.}:}.}
%list%

[file.mp3 = file.mpeg = file.mp4 = file.wmv = file.wma = file.avi = file.flac = file.wav = file.ogg = file.ogm = file.mkv = file.mka]
%item-full-url%

[folder]
%item-name%/

It only includes media files, but probably the list is far from complete.
%item-full-url% returns the correct absolute link, but it is not listed here: http://www.rejetto.com/wiki/index.php/HFS:_Template_symbols.

Mijo