Sign in to follow this  
Followers 0
therms

Podcast parsing UDF

2 posts in this topic

With this function you can parse the RSS feed of a podcast to extract titles and URLs.

This is the hardest part of getting podcasts. With the array that this function returns you can then InetGet the podcasts you want easily. I've tested this on only a half dozen podcast feeds or so.

Of course, this could be extended or integrated with a larger app with more features such as keeping track of which podcasts you've downloaded already, getting only the last xx podcasts, etc.

I'm sure there's probably better ways to do some of these things. For example, the way I join the two arrays feels kind of 'kludgy' to me. It could also probably do with more error handling...

;===============================================================================
; Function Name:    _PodCastXMLParse
; Description:      Parses XML for podcast feed and returns a 2D array with titles and URLs.
; Parameter(s):     $feed   File containing feed XML
; Syntax:           _PodCastXMLParse($feed)
; Return Value(s):  On Success an array where
;                       $array[0][0] = Size of array 
;                       $array[1][0] = Title
;                       $array[1][1] = URL
;                       ...
;                       $array[n][0] = Title
;                       $array[n][1] = URL
;                   On Failure  - Returns -1 
; Dependency:       _XMLDomWrapper (http://www.autoitscript.com/forum/index.php?showtopic=19848)
; Author(s):        Dustin Wyatt <dmwyatt@contriving.net>
;===============================================================================
Func _PodCastXMLParse($feed)
    $xmlfile = $feed
    
    $xml = _XMLFileOpen($xmlfile)
    $aTitles = _XMLGetValue("/rss/channel/item/title")

    Dim $aValues[1], $aNames[1], $aFiles[$aTitles[0] + 1]

    $aFiles[0] = $aTitles[0]
    For $i = 0 To $aTitles[0] - 1
        $file_ret = _XMLGetAllAttribIndex("/rss/channel/item/enclosure", $aNames, $aValues, "", $i)
        If $file_ret = -1 Then
            Return -1
        EndIf
        $aFiles[$i + 1] = $aValues[0]
    Next
    
    If $aTitles[0] == $aFiles[0] Then ; Join the two arrays
        Dim $aTitles_Files[$aTitles[0] + 1][2]
        $aTitles_Files[0][0] = $aTitles[0]
        $aTitles_Files[0][1] = $aFiles[0]
        For $i = 1 To $aTitles_Files[0][0]
            $aTitles_Files[$i][0] = $aTitles[$i]
            $aTitles_Files[$i][1] = $aFiles[$i]
        Next
    Else
        Return -1
    EndIf

    Return $aTitles_Files
EndFunc   ;==>PodCastXMLParseoÝ÷ Ø   ÝêÞßÛìZ^¡ø­ßÛ.±æ®¶­sb6æ6ÇVFRfÇCµõÔÄFöÕw&W"æS2fwC°¢6æ6ÇVFRfÇC´'&æS2fwC°¤æWDvWBgV÷C¶GG¢òöÆV÷fÆÆRçGb÷öF67G2÷GvBçÖÂgV÷C²ÂgV÷C·GvBçÖÂgV÷C²¢b33c¶67G2ÒõöD67EÔÅ'6RgV÷C·GvBçÖÂgV÷C²¥ô'&F7Æb33c¶67G2

Share this post


Link to post
Share on other sites



Wonderful, from your bit of example code I see that we would use this for the same thing. I have written a basic podcast downloader in perl that I used to get my daily feeds. As you mentioned it does keep track of what I have allready downloaded. Writing somthing in AutoIt to do it would be fun.

Thanks!


AutoIt changed my life.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0