~ubuntu-branches/ubuntu/oneiric/rhythmbox/oneiric

« back to all changes in this revision

Viewing changes to plugins/context/LastFM.py

  • Committer: Bazaar Package Importer
  • Author(s): Rico Tzschichholz
  • Date: 2011-07-29 16:41:38 UTC
  • mto: This revision was merged to the branch mainline in revision 191.
  • Revision ID: james.westby@ubuntu.com-20110729164138-wwicy8nqalm18ck7
Tags: upstream-2.90.1~20110802
ImportĀ upstreamĀ versionĀ 2.90.1~20110802

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- Mode: python; coding: utf-8; tab-width: 8; indent-tabs-mode: t; -*-
 
2
#
 
3
# Copyright (C) 2009 Jonathan Matthew
 
4
#
 
5
# This program is free software; you can redistribute it and/or modify
 
6
# it under the terms of the GNU General Public License as published by
 
7
# the Free Software Foundation; either version 2, or (at your option)
 
8
# any later version.
 
9
#
 
10
# The Rhythmbox authors hereby grant permission for non-GPL compatible
 
11
# GStreamer plugins to be used and distributed together with GStreamer
 
12
# and Rhythmbox. This permission is above and beyond the permissions granted
 
13
# by the GPL license by which Rhythmbox is covered. If you modify this code
 
14
# you may extend this exception to your version of the code, but you are not
 
15
# obligated to do so. If you do not wish to do so, delete this exception
 
16
# statement from your version.
 
17
#
 
18
# This program is distributed in the hope that it will be useful,
 
19
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
20
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
21
# GNU General Public License for more details.
 
22
#
 
23
# You should have received a copy of the GNU General Public License
 
24
# along with this program; if not, write to the Free Software
 
25
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA.
 
26
 
 
27
import os
 
28
import ConfigParser
 
29
 
 
30
from gi.repository import RB
 
31
 
 
32
# utility things for dealing with last.fm
 
33
 
 
34
URL_PREFIX = 'http://ws.audioscrobbler.com/2.0/?method='
 
35
 
 
36
# this is probably john iacona's key
 
37
API_KEY = '27151108bfce62e12c1f6341437e0e83'
 
38
 
 
39
NO_ACCOUNT_ERROR = _("This information is only available to Last.fm users. Ensure the Last.fm plugin is enabled, select Last.fm in the side pane, and log in.")
 
40
 
 
41
def user_has_account():
 
42
    session_file = os.path.join(RB.user_data_dir(), "audioscrobbler", "sessions")
 
43
 
 
44
    if os.path.exists(session_file) == False:
 
45
        return False
 
46
 
 
47
    sessions = ConfigParser.RawConfigParser()
 
48
    sessions.read(session_file)
 
49
    try:
 
50
        return (sessions.get('Last.fm', 'username') != "")
 
51
    except:
 
52
        return False
 
53
 
 
54
def datasource_link(path):
 
55
    return "<a href='http://last.fm/'><img src='%s/img/lastfm.png'></a>" % path