示例#1
0
def get_list_popular_music(request):
    perido = request.GET.get('period')
    client = Client()
    client.init()
    if perido == '1':
        popular_music = client.popular(period=Client.DAILY)
    else:
        popular_music = client.popular(period=Client.MONTHLY)
    musicas = []
    for musica in popular_music:
        musicas.append(musica.export())
    return HttpResponse(json.dumps(musicas), mimetype="application/json")
示例#2
0
def PlayMusic(self, userinput):
    client = Client()
    client.init()

    searchquery = userinput.split("song")[1]

    try:
        song = next(client.search(searchquery, type='Songs'))
        p = subprocess.Popen([
            "exec cvlc " + song.stream.url + " vlc://quit --quiet > /dev/null"
        ],
                             shell=True)

        return "Playing " + str(song)
    except StopIteration:
        return "It don't see that song."
示例#3
0
def download_musics(request):
    musicas = json.loads(request.GET.get('musicas', '[]'))
    if musicas:
        client = Client()
        client.init()
        musics_list = []
        for musica in musicas:
            song = Song.from_export(musica, client.connection)
            musics_list.append(song)
        zip_path = download_music_temp_file(musics_list)

        response = HttpResponse(FileWrapper(file(zip_path)),
                                content_type='application/zip',
                                mimetype="application/zip")
        response['Content-Disposition'] = 'attachment; filename=myfile.zip'
        response['Content-Length'] = os.path.getsize(zip_path)
        return response
    else:
        raise Http404
示例#4
0
def search_for_musics(query, option):
    client = Client()
    client.init()
    musicas_list = []
    if option == '1':
        musicas = client.search(query, Client.SONGS)
        for musica in musicas:
            musicas_list.append(musica.export())
    elif option == '2':
        musicas = client.search(query, Client.ALBUMS)
        for musica in musicas:
            musicas_list.append(musica.export())
    elif option == '3':
        musicas = client.search(query, Client.ARTISTS)
        for musica in musicas:
            musicas_list.append(musica.export())
    elif option == '4':
        playlist = client.playlist(query)
        for musica in playlist:
            musicas_list.append(musica.export())
    else:
        musicas_list = []
    return musicas_list
示例#5
0
app.config['DEBUG'] = True
#mongo = PyMongo(app)
MONGO_URL = os.environ.get('MONGOHQ_URL')

if MONGO_URL:
    # Get a connection
    conn = pymongo.Connection(MONGO_URL)

    # Get the database
    db = conn[urlparse(MONGO_URL).path[1:]]
else:
    # Not on an app with the MongoHQ add-on, do some localhost action
    conn = pymongo.Connection('localhost', 27017)
    db = conn['someapps-db']

gsClient = Client()
gsClient.init()
gsClient.init_token()
gsClient.init_queue()


@app.route('/')
def hello():
    post = {"test": "tes1"}
    db.abc.insert(post)
    return 'Hello World!'


@app.route('/ooh')
def hii():
    post_id = db.abc.find_one()
# -*- coding:utf-8 -*-
#
# Copyright (C) 2012, Maximilian Köhl <*****@*****.**>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from __future__ import print_function

import subprocess

from grooveshark import Client

client = Client()
client.init()

for song in client.popular():
    print(song)
    subprocess.call(['mplayer', song.stream.url])
示例#7
0
 def __init__(self):
     super().__init__()
     self.client = Client()
     self.client.init()
     self._cache = {}
     self._cache['streams'] = {}
示例#8
0
 def __init__(self):
     self.client = Client()
     self.client.init()
from gmusicapi import Mobileclient
from grooveshark import Client
import sys

api = Mobileclient()
api.login(sys.argv[1], sys.argv[2])

groove_client = Client()

playlist = groove_client.playlist(sys.argv[3])

gp_songs = []

for song in playlist.songs:
    query = song.name + " " + song.artist.name
    gp_query_result = api.search_all_access(query, 1)
    try:
        track = gp_query_result['song_hits'][0]['track']
        print("Adding " + track['title'] + " by " + track['artist'])
        gp_songs.append(track['nid'])
    except IndexError as e:
        print("Coudn't find " + query)
        pass
    except:
        print(e)
        pass

gp_playlist = api.create_playlist(playlist.name)
api.add_songs_to_playlist(gp_playlist, gp_songs)
示例#10
0
import nltk
import nlpy
import en

import psw
import gapi

import player

songPlayer = player.Player()
player.init()

import subprocess
from grooveshark import Client
songClient = Client()
songClient.init()

from sets import Set


def matchWord(tokens, words):
    s = Set(tokens).intersection(Set(words))
    if len(s) > 0:
        return [(w, 1.0, w) for w in s]
    else:
        from nltk.metrics import distance
        import operator
        result = []
        for token in Set(tokens):
            vals = {