Writing callbacks for mediaRSS

  This is a running log of my progress on writing callbacks to create a mediaRSS feed in Radio2
  Concept
    Easiest way seems to add some kind of 'trigger' in the Description field of the post that will alert the callbacks to work.
    Something like: [THUMBNAIL:https://s3.amazonaws.com/adamcurry/BAS+Appisodes/2011/03/10/aloqaLabel.png]
    The script needs to:
    recognize it
    write the namespace tag appropriately
    erase the trigger from the post
  Approach
    First I want to see if I can get the callbacks to work at all, by using the example script.
      on addRandomNumber (adruser, adrfeed)
        return ("" + random (1, 1000) + "")
      bundle //test code
        dialog.alert (addRandomNumber (nil, nil))
    3/11/11; 11:06:22 AM by AC Good News, It Worked!
      http://xmlviewer.scripting.com/?url=http://testing.curry.com/linkblog.xml
    Attempting to get the item level call backs to work. This sin't happening for some reason with the test script.
    I think I have to change the adrfeed to something like adritem
    adritem isn't the right one.
    I'm now going to walk through the post code to see if I can figure out what gets written and what adr I need to be looking at.
    OK, I was missing a parameter. The full list is: (adruser, adrfeed, adritem)
    3/11/11; 11:41:25 AM by AC It is now writing my thumbnail at the item level
    3/11/11; 11:50:02 AM by AC HA! I was able to create a 'trap'. by adding the string [THUMBNAIL] to the post, it triggered a write from the callback with a URL, without the trigger word, it wrote a line saying it didn't work.
    Here's my trap testing code
      on addThumbnail (adruser, adrfeed, adritem)
        if adritem^.description contains "[THUMBNAIL]"
          return ("" + "https://s3.amazonaws.com/adamcurry/BAS+Appisodes/2011/03/10/aloqaLabel.png" + "")
        else
          return ("" + "The trap didn't work" + "")
      bundle //test code
        dialog.alert (addThumbnail (nil, nil, nil))
    Now I have to figure out the following:
      Use the trigger word followed by a URL to the thumbnail
      Add ONLY the url to the callback write
      Delete the whole trigger line from the post so it doesn't get written in the feed.
    Some success
      I can now get the thumbnail url parsed and into the callback with this code:
        on addThumbnail (adruser, adrfeed, adritem)
          if adritem^.description contains "THUMBNAIL:"
            s = string.firstWord (adritem^.description)
            s = string.delete (s, 1, 10)
            return ("" + s + "")
          else
            return ("" + "The trap didn't work" + "")
        bundle //test code
          dialog.alert (addThumbnail (nil, nil, nil))
      Now I need to delete the url and the trigger from the actual post.
      If possible
    I got pretty far!
    I now can add the trigger, have the url written and the trigger removed from the description, but I still have to publish twice in order for the trigger to get stripped out of the description in the actual feed.
    All in all not bad!
    Here's the code:
      on addThumbnail (adruser, adrfeed, adritem)
        if not defined (adritem^.thumbnail) and adritem^.description contains "THUMBNAIL:"
          s = string.firstWord (adritem^.description)
          s = string.delete (s, 1, 10)
          table.assign (@adritem^.thumbnail, s)
          t = adritem^.thumbnail
          table.assign (@scratchpad.adamTemp, adritem^.description)
          z = string.replace (scratchpad.adamTemp, "THUMBNAIL:" + t, "")
          table.assign (@adritem^.description, z)
          return ("" + t + "")
        else
          t = adritem^.thumbnail
          return ("" + t + "")
      bundle //test code
        dialog.alert (addThumbnail (nil, nil, nil))
  If you want to skip over all the steps I went through and see the final code, it's here:
    on addThumbnail (adruser, adrfeed, adritem)
      if not defined (adritem^.thumbnail) and adritem^.description contains "THUMBNAIL:"
        s = string.firstWord (adritem^.description)
        s = string.delete (s, 1, 10)
        table.assign (@adritem^.thumbnail, s)
        t = adritem^.thumbnail
        table.assign (@scratchpad.adamTemp, adritem^.description)
        z = string.replace (scratchpad.adamTemp, "THUMBNAIL:" + t, "")
        table.assign (@adritem^.description, z)
        return ("\r\t\t\t\t\r\t\t\t")
      else
        t = adritem^.thumbnail
        return ("\r\t\t\t\t\r\t\t\t")
    bundle //test code
      dialog.alert (addThumbnail (nil, nil, nil))
  3/11/11; 5:19:27 PM by AC
  I see now that I am running into a problem, I need to be able to declare the namespace for media content. Hopefully there is a callback to do that somehwere in here...
  Line needed: "+"\r\t\txmlns:media=\"http://search.yahoo.com/mrss/\"