Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - ASP Podcasting Script - RSS Feed
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

ASP Podcasting Script - RSS Feed

 Post Reply Post Reply
Author
xeerex View Drop Down
Senior Member
Senior Member


Joined: 19 November 2002
Location: United States
Status: Offline
Points: 601
Post Options Post Options   Thanks (0) Thanks(0)   Quote xeerex Quote  Post ReplyReply Direct Link To This Post Topic: ASP Podcasting Script - RSS Feed
    Posted: 13 May 2005 at 2:28am
Hey guys,

I've just started getting into podcasting and wanted an easy way to upload my mp3 files and have a script put in the information. Naturally, I found a PHP script but nothing in ASP. Then I found this script that uses Stream Object, which helped me out tremendously, but the problem is that it reads IDv1.x tags. While that is not a huge deal, it would be even better if someone knew how to read IDv2.x tags. Any ideas?Confused

I'm about to start building a site at www.podcastgeek.com, although my mp3's will be hosted under rexpage.com (more bandwidth). You can see my script in action (which is also the podcast feed for my tech podcasts) at:

http://www.rexpage.com/podcasts/tech

Also, here is the code for the podcast script. Any updates will be found on my forum at www.rexpage.com/forum and I'll have information at www.podcastgeek.com once it is live.

Zip file for Code

[code]
<?xml version="1.0" encoding="ISO-8859-1" ?>

<!--METADATA TYPE="typelib"
      UUID="00000205-0000-0010-8000-00AA006D2EA4"
     NAME="ADODB Type Library"
-->

<%
'#####################
'This code is released freely for use
'by the podcasting community. Parts of
'the code are from other sources as credited.
'Please check out my podcast site at www.podcastgeek.com
'and make a donation if this script helps you out.
'
'xxxIMPORTANTxxxxx
'This script will support ID3v1.x and ID3v2.x tags but
'the positions are not correct from several in ID3v2.x format
'
'If you know how to use Stream Object to read
'ID3v2 tags then let me know.
'
'xxxNOTICE ABOUT AUDIOSHELL 1.0xxx
'For some reason, if you use AudioShell 1.0 under Windows
'to edit your ID3 tags, this script will not read them.
'I recommend that you use iTunes or the tags generated from
'Audacity.
'
'Apple's iTunes works fine using ID3v1.x and ID3v2.x
'
'xxxHOW TO USE THIS SCRIPTxxx
'FTP this script in the same folder as your mp3 files.
'It should automatically find the files and create the
'RSS feed.
'
'You can modify this script to find other audio formats
'such as oog vorbis, etc. To do this edit the If Then statement
'or replace it with a Select Case in the appropriate lines.
'
'EDITABLE Information - BEGIN
'#####################

'Specify the folder to look through, displaying all the MP3s
folder = Server.MapPath(".") 'This is the easy way to map to this folder

'folder = "c:\yourwebfolder\yourmp3folder" 'Uncomment this one if you like the physical path


'Set the RSS Feed Information
strTitle         = "PodcastGeek.com Tech Podcast Feed"
strWebsiteURL     = "http://www.podcastgeek.com"
strFeedURL        = "http://www.rexpage.com/podcasts/tech"    'Do not put a trailing / here
strDescription    = "Rex's Podcasts"
strGenerator    = "PodcastGeek.com Podcasting ASP Script"

'#####################
'END OF EDITABLE (unless you know what you are doing)
'#####################

'Lets set the date of the publication
strDate = fncFmtDate(Now(), "%a, %d %b %Y %H:%N:%S CST")

'Start RSS
'The RSS syntax is VERY precise so be careful!
    Response.ContentType = "text/xml"
    Response.Write("<rss version=""2.0"">")    'If you get any XML errors then comment out this line
    Response.Write("<channel>")
    Response.Write("<title>"& strTitle &"</title>")
    Response.Write("<link>"& strWebsiteURL &"</link>")
    Response.Write("<description>"& strDescription &"</description>")
    Response.Write("<language>en-us</language>")
    Response.Write("<copyright>Copyright 2004 "& strTitle &" - All Rights Reserved.</copyright>")
    Response.Write("<generator>"& strGenerator &"</generator>")
    Response.Write("<pubDate>"& strDate &"</pubDate>")
    Response.Write("<ttl>60</ttl>")

'##############################
'Start of reading mp3 ID tags
'Credit: http://www.4guysfromrolla.com/webtech/tips/t041701-1.shtml
'##############################
 
  Function ConvertBin(Binary)
  'This function converts a binary byte into an ASCII byte.
    for i = 1 to LenB(Binary)
      strChar = chr(AscB(MidB(Binary,i,1)))
      ConvertBin = ConvertBin & strChar
    Next
  End Function

  dim objStream
  dim strTag, strSongName, strArtist, strAlbum, strYear, _
      strComment, strGenre, strFile

  'Grab the folder information
  'For more information on this technique below, check out this FAQ:
  '  http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=90
  Dim objFSO, objFolder, objFile
  Set objFSO = Server.CreateObject("Scripting.FileSYstemObject")
  Set objFolder = objFSO.GetFolder(folder)

  'Create the Stream object
  set objStream = Server.CreateObject("ADODB.Stream")
  objStream.Type = adTypeBinary

  'Loop through the files in the folder
  For Each objFile in objFolder.Files
     
    'Get the file extension for each object
    Extension = objFSO.GetExtensionName(objFile)
 
    'Loop only through the mp3 files and get the tag information
    If Extension = "mp3" Then
   
    'Open the stream
    objStream.Open
    objStream.LoadFromFile objFile.Path

    'Read the last 128 bytes
    objStream.Position =  objStream.size - 128

    'Read the ID3 v1 tag info
    strTag = ConvertBin(objStream.Read(3))
    if ucase(strTag) = "TAG" then
      strSongName = ApplyXMLFormatting(ConvertBin(objStream.Read(30)))
      strArtist = ApplyXMLFormatting(ConvertBin(objStream.Read(30)))
      strAlbum = ApplyXMLFormatting(ConvertBin(objStream.Read(30)))
      strYear = ApplyXMLFormatting(ConvertBin(objStream.Read(4)))
      strComment = ApplyXMLFormatting(ConvertBin(objStream.Read(30)))
    end if

'Create the enclosure URL for the audio file
strEncl
Back to Top
Bluefrog View Drop Down
Senior Member
Senior Member


Joined: 23 October 2002
Location: Korea, South
Status: Offline
Points: 1701
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bluefrog Quote  Post ReplyReply Direct Link To This Post Posted: 16 May 2005 at 10:23am
You can use the same basic technique as the 4guys script. Just look for the tags as you go along. You can also use a COM object to do the reading for you, which is easier. It needs to be installed on the server then though. There are a couple out there that are free.
Back to Top
xeerex View Drop Down
Senior Member
Senior Member


Joined: 19 November 2002
Location: United States
Status: Offline
Points: 601
Post Options Post Options   Thanks (0) Thanks(0)   Quote xeerex Quote  Post ReplyReply Direct Link To This Post Posted: 16 May 2005 at 10:54am
Originally posted by wrote:

Just look for the tags as you go along.


Thanks -- want to clarify that some?

Originally posted by wrote:

You can also use a COM object to do the reading for you, which is easier. It needs to be installed on the server then though. There are a couple out there that are free.


Thanks again -- but I want it script only. Installing objects on the server is not usually an option for most sites as they are on shared hosting.
Back to Top
xeerex View Drop Down
Senior Member
Senior Member


Joined: 19 November 2002
Location: United States
Status: Offline
Points: 601
Post Options Post Options   Thanks (0) Thanks(0)   Quote xeerex Quote  Post ReplyReply Direct Link To This Post Posted: 16 May 2005 at 3:05pm
Update to Script:

(1) Uses Server.MapPath now for easier implementation

(2)I just figured out why I was having issues with the script reading mp3 files after editing the ID3 tags. I was using AudioShell 1.0 under Windows which causes some sort of issue with the ID3 tags under that script. It will read ID3v1.x tags and 2.x if you use Audacity's tag editor or iTunes.

I still cannot get all of the information from the 2.x tags though since that information is stored at the beginning of the file and is quite a bit more difficult to handle even though it is far more flexible and robust. If anyone can help out it would be greatly appreciated. I would like to be able to read the entire comment information rather than be limited to v1.x comments and 30 bytes.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.