Print Page | Close Window

ASP Podcasting Script - RSS Feed

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=15067
Printed Date: 30 March 2026 at 3:20am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: ASP Podcasting Script - RSS Feed
Posted By: xeerex
Subject: ASP Podcasting Script - RSS Feed
Date 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 http://www.shadydentist.com/wordpress/archives/2004/10/13/dircaster-01/ - PHP script but nothing in ASP. Then I found http://www.4guysfromrolla.com/webtech/tips/t041701-1.shtml - 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 http://www.podcastgeek.com - 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 - 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 http://www.podcastgeek.com - www.podcastgeek.com once it is live.

http://www.rexpage.com/files/Script_ASP_Podcast.zip - 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

-------------
http://webspacegeeks.com - Need Hosting, Domains, Dedicated Servers?
http://www.smartergeek.com - web design | pc support | training | podcasts | video production



Replies:
Posted By: Bluefrog
Date 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.

-------------
http://renegademinds.com/" rel="nofollow - Renegade Minds - Guitar Software http://renegademinds.com/Default.aspx?tabid=65" rel="nofollow - Slow Down Music


Posted By: xeerex
Date 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.


-------------
http://webspacegeeks.com - Need Hosting, Domains, Dedicated Servers?
http://www.smartergeek.com - web design | pc support | training | podcasts | video production


Posted By: xeerex
Date 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.


-------------
http://webspacegeeks.com - Need Hosting, Domains, Dedicated Servers?
http://www.smartergeek.com - web design | pc support | training | podcasts | video production



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net