
import re
import urllib

def handle_url(bot, user, channel, url, msg):
    """Handle IMDB urls"""
    
    m = re.match("(http:\/\/open.spotify.com\/|spotify:)(album|artist|track)([:\/])([a-zA-Z0-9]+)\/?", url)
    if not m: return

    dataurl = "http://spotify.url.fi/%s/%s?txt" % (m.group(2), m.group(4))

    f = urllib.urlopen(dataurl)
    songinfo = f.read()
    f.close()

    artist, album, song = songinfo.split("/", 2)

    bot.say(channel, "[Spotify] Artist: %s - Album: %s - Song: %s" % (artist.strip(), album.strip(), song.strip()))


import re
import urllib

def handle_url(bot, user, channel, url, msg):
    """Handle IMDB urls"""
    
    m = re.match("(http:\/\/open.spotify.com\/|spotify:)(album|artist|track)([:\/])([a-zA-Z0-9]+)\/?", url)
    if not m: return

    dataurl = "http://spotify.url.fi/%s/%s?txt" % (m.group(2), m.group(4))

    f = urllib.urlopen(dataurl)
    songinfo = f.read()
    f.close()

    artist, album, song = songinfo.split("/", 2)

    bot.say(channel, "[Spotify] %s - %s (%s)" % (artist.strip(), song.strip(), album.strip()))

Change output format to a more reasonable one
Change output format to a more reasonable one


git-svn-id: 056f9092885898c4775d98c479d2d33d00273e45@143 dda364a1-ef19-0410-af65-756c83048fb2

  
  import re
  import urllib
  
  def handle_url(bot, user, channel, url, msg):
      """Handle IMDB urls"""
      
      m = re.match("(http:\/\/open.spotify.com\/|spotify:)(album|artist|track)([:\/])([a-zA-Z0-9]+)\/?", url)
      if not m: return
  
      dataurl = "http://spotify.url.fi/%s/%s?txt" % (m.group(2), m.group(4))
  
      f = urllib.urlopen(dataurl)
      songinfo = f.read()
      f.close()
  
      artist, album, song = songinfo.split("/", 2)
  
-     bot.say(channel, "[Spotify] Artist: %s - Album: %s - Song: %s" % (artist.strip(), album.strip(), song.strip()))
+     bot.say(channel, "[Spotify] %s - %s (%s)" % (artist.strip(), song.strip(), album.strip()))
  
Change output format to a more reasonable one
## Code Before:

import re
import urllib

def handle_url(bot, user, channel, url, msg):
    """Handle IMDB urls"""
    
    m = re.match("(http:\/\/open.spotify.com\/|spotify:)(album|artist|track)([:\/])([a-zA-Z0-9]+)\/?", url)
    if not m: return

    dataurl = "http://spotify.url.fi/%s/%s?txt" % (m.group(2), m.group(4))

    f = urllib.urlopen(dataurl)
    songinfo = f.read()
    f.close()

    artist, album, song = songinfo.split("/", 2)

    bot.say(channel, "[Spotify] Artist: %s - Album: %s - Song: %s" % (artist.strip(), album.strip(), song.strip()))

## Instruction:
Change output format to a more reasonable one
## Code After:

import re
import urllib

def handle_url(bot, user, channel, url, msg):
    """Handle IMDB urls"""
    
    m = re.match("(http:\/\/open.spotify.com\/|spotify:)(album|artist|track)([:\/])([a-zA-Z0-9]+)\/?", url)
    if not m: return

    dataurl = "http://spotify.url.fi/%s/%s?txt" % (m.group(2), m.group(4))

    f = urllib.urlopen(dataurl)
    songinfo = f.read()
    f.close()

    artist, album, song = songinfo.split("/", 2)

    bot.say(channel, "[Spotify] %s - %s (%s)" % (artist.strip(), song.strip(), album.strip()))
