From bbdfb23e16befa980f63cbd9b1500cbe68df5a5c Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Thu, 7 Feb 2013 03:24:30 +1300 Subject: [PATCH] Added Spotify search command. --- plugins/data/fortunes.txt | 8 ++++++-- plugins/spotify.py | 9 +++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/plugins/data/fortunes.txt b/plugins/data/fortunes.txt index e9bfcc3..d425f26 100755 --- a/plugins/data/fortunes.txt +++ b/plugins/data/fortunes.txt @@ -9,6 +9,7 @@ A starship ride has been promised to you by the galactic wizard. That wasn’t chicken. You will become a hermit and be sad and lonely for the rest of your life. Don’t fry bacon in the nude. +The road to riches is paved with homework. Take calculated risks. That is quite different from being rash. DO THE IMPOSSIBLE, SEE THE INVISIBLE. You cannot plough a field by turning it over in your mind. Unless you have telekinesis. @@ -17,12 +18,13 @@ Never lose the ability to find beauty in ordinary things. Ignore previous fortune. Smile more. YOU'RE THE BEST AROUND, NOTHIN'S GONNA EVER KEEP YA DOWN. -The cake is a lie. +The cake is not a lie. Never take life seriously. Nobody gets out alive anyway. Friendship is like peeing on yourself: everyone can see it, but only you get the warm feeling that it brings. Never go to a doctor whose office plants have died. Always remember you're unique, just like everyone else. -What if everything is an illusion and nothing exists? In that case, I definitely overpaid for my carpet. +What if everything is an illusion and nothing exists? (In that case, I definitely overpaid for my carpet) +Don’t be discouraged, because every wrong attempt discarded is another step forward. Even if you are on the right track, you will get run over if you just sit there. Think like a man of action, and act like a man of thought. When in doubt, lubricate. @@ -36,6 +38,7 @@ You will die, but become reanimated as a Zombie, and forever roam the earth in s This message will self destruct in 10 seconds. You will live a normal life, with a normal home, a normal job, and a normal future. You'll never know what you can do until you try. +A person of words and not deeds is like a garden full of weeds. You are talented in many ways Be both a speaker of words and a doer of deeds. A visit to a strange place will bring you renewed perspective. @@ -49,5 +52,6 @@ You can expect a change for the better in job or status in the future. As the wallet grows, so do the needs. You have a reputation for being straightforward and honest. Learn a new language and get a new soul. +A dubious friend may be an enemy in camouflage. A tall dark stranger will soon enter our life. Keep staring. I'll do a trick. diff --git a/plugins/spotify.py b/plugins/spotify.py index a971711..935e118 100644 --- a/plugins/spotify.py +++ b/plugins/spotify.py @@ -9,6 +9,15 @@ spotify_re = (r'(spotify:(track|album|artist|user):([a-zA-Z0-9]+))', re.I) http_re = (r'(open\.spotify\.com\/(track|album|artist|user)\/' '([a-zA-Z0-9]+))', re.I) +@hook.command +def spotify(inp): + "spotify -- Search Spotify for " + data = spotimeta.search_track(inp.strip()) + type, id = data["result"][0]["href"].split(":")[1:] + url = gateway.format(type, id) + return u"{} by {} - {}".format(data["result"][0]["name"], data["result"][0]["artist"]["name"], url) + + @hook.regex(*http_re) @hook.regex(*spotify_re) def spotify_url(match):