1. Soma.fm + Spotify + import.io + Python mashup: automatically create a Spotify playlist with Soma.fm tracks

    I'm a big fan of Soma.fm (a 25+ channels streaming radio based in San Francisco) and during the years I've been writing clients for this radio for different mobile platforms (Maemo, MeeGo, Harmattan, Windows Phone, BlackBerry 10, Jolla). I love in particular their "Indie Pop Rock" channel that during these years made me discover some very good artists.

    When Spotify finally was available in Italy (I'm still using it right now that I live in the UK), something that I always missed was a radio with the same good music. Why not just listening to Soma.fm? Because I like to listen to the music while I commute and in the London Underground it's nearly impossible to have signal.

    So I was thinking: it would be nice to have a Spotify playlist with Soma.fm tracks. Wait a moment.... I can do it!

    Frankenstein_Jr_Mel_Brooks_1974{.aligncenter .size-full .wp-image-981 width="542" height="422"}

    Soma.fm publishes the tracks history with all the tracks streamed during the last hour http://somafm.com/indiepop/songhistory.html so I just needed something to parse this list for me and return me a well formatted version.

    Thanks to import.io (it's a service that takes a web page as input, parse the data and generates a RESTful API to access this data) I was able to easily get the data I needed. At this point I only needed to be able to loop through the list, search each track on Spotify and add it to my playlist.

    The source code is fully available here https://github.com/andreagrandi/spotisoma

    Note: you can't just get the code and run it. You will need to get your own import.io api key, generate your import.io api url, get a Spotify application key (the old/deprecated one, since it was nearly impossible for me to use oauth in a simple Python script due to the fact I didn't have an endpoint to receive the token back. You can get more informations here: https://pyspotify.mopidy.com/en/latest/quickstart/#application-keys) and set your env variables with your Spotify username and password. Last but not least: the old Spotify library only works with Premium accounts.

    read more


  2. PyngFM: Python implementation of Ping.fm API

    Thu 02 April 2009 | in Python

    ping.fm{.alignright .size-full .wp-image-257 width="99" height="97"}I've just released PyngFM, a Python implementation of Ping.fm API. Ping.fm is a simple service that allow you to update multiple social networks (Facebook, Twitter, Jaiku ecc...) with a single post. You can find complete source code and documentation on the official website: http://code.google.com/p/pyngfm/

    Please contact me if you have any suggestion or if you find any bug in the code, so I'll be able to fix it.

    read more


  3. Il crivello di Eratostene

    Questo codice Python di esempio, genera una lista di numeri primi che vanno da 2 fino al numero passato come parametro.

    [sourcecode language='python']
    def eratostene(x):
    primi = range(3, x + 1, 2)
    for i in primi:
    if(pow(i, 2) > x):
    for j in primi:
    if(i != j) and (j % i == 0):
    primi.insert(0, 2)
    return primi

    read more


« Page 2 / 2