def itunes_cache(directory=None):
    '''
    Enables caching, in the specified cache directory
    @param  __cache_dir:  string
    '''
    import itunes
    
    return itunes.enable_caching(directory) if directory else False
示例#2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
import cjb, itunes, json, sys

if len(sys.argv) > 1:
	uartist = sys.argv[1]
	ualbum = sys.argv[2]
	utrack = sys.argv[3]
else:
	exit(0)

if not itunes.is_caching_enabled():
	itunes.enable_caching('/tmp/itunes_cache')

score = 0
url = {'itunes':''}

try:
	artist = itunes.search_artist(uartist)[0]
	if uartist == artist.get_name() or cjb.simple_compare(uartist, artist.get_name(), .90):
		url['itunes'] = artist.get_url()

		for album in artist.get_albums():
			albumscore = 0
		
			if ualbum == album.get_name():
				albumscore += 32
			elif cjb.simple_compare(ualbum, album.get_name(), .80):
				albumscore += 20
		
示例#3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import cjb, itunes, json, sys

if len(sys.argv) > 1:
    uartist = sys.argv[1]
    ualbum = sys.argv[2]
    utrack = sys.argv[3]
else:
    exit(0)

if not itunes.is_caching_enabled():
    itunes.enable_caching('/tmp/itunes_cache')

score = 0
url = {'itunes': ''}

try:
    artist = itunes.search_artist(uartist)[0]
    if uartist == artist.get_name() or cjb.simple_compare(
            uartist, artist.get_name(), .90):
        url['itunes'] = artist.get_url()

        for album in artist.get_albums():
            albumscore = 0

            if ualbum == album.get_name():
                albumscore += 32
            elif cjb.simple_compare(ualbum, album.get_name(), .80):
                albumscore += 20
示例#4
0
from bs4 import BeautifulSoup
import requests
import re
import logging
import itunes

YOUTUBE_URL = "https://www.youtube.com/results?search_query=%s"

video_cache = {}

if not itunes.is_caching_enabled():
    itunes.enable_caching("/tmp/itunes_cache")  # If no param given it creates a folder in /tmp
logging.info("Caching artwork in %s", itunes.__cache_dir)


def get_artwork(song):
    song_name = re.sub(r"\([^)]*\)", "", song[1]).strip().lower()
    artist = song[0].lower()
    results = itunes.search("%s %s" % (song_name, artist), limit=1)
    if not results:
        return {}
    return results[0].artwork


def get_video(song):
    if song in video_cache:
        return video_cache[song]
    song_html = requests.get(YOUTUBE_URL % ("%s %s" % (song[0].lower(), song[1].lower()))).text
    soup = BeautifulSoup(song_html, "html.parser")
    links = soup.find_all("ol", {"class": "section-list"})[0].find_all("a")
    for link in links:
示例#5
0
文件: itunez.py 项目: spekode/Boteh
__Name__ = "iTunez"
__Author__ = "B1naryth1ef"
__Version__ = 0.1
__Usage__ = 'Usage: !itunes [album/music/video/help] ["song/band/etc"] [page]'
import itunes, bitly

bit_key = "R_42e64ea1b847569fa240fea085d731d4"
bit_login = "******"

if not itunes.is_caching_enabled():
    itunes.enable_caching("./.itunes_cache")

bapi = bitly.Api(login=bit_login, apikey=bit_key)


def shorten(url):
    return bapi.shorten(url)


def itunesm(msg):
    api.sendMsg(msg.channel, "Loading...")
    resultz = {}
    if len(msg.message.split(" ")) < 2:
        api.sendMsg(msg.channel, __Usage__)
    try:
        _msg = msg.message.split(" ")
        _msg2 = msg.message.split('"')
        _query = _msg2[1]
        _cmd = _msg[0]
        _mode = _msg[1]
        _page = _msg2[2]
示例#6
0
from __future__ import unicode_literals

import logging
import random
from mopidy.audio import PlaybackState
from mopidy.models import TlTrack
from bbmodels import bbTrack
import itunes
if not itunes.is_caching_enabled():
      itunes.enable_caching()
import urllib
from mopidy.core import listener
import os
import operator

logger = logging.getLogger('mopidy.bb')
from mopidy import settings
cover_dir=""

class bbTracklistController(object):
    pykka_traversable = True

    def __init__(self, core,config):
        self._core = core
        self._next_tlid = 1
        self._bb_tracks = []
        self._version = 0
        self._tl_length=0
        self.playingSong=None
        if config['http']['static_dir']:
            cover_dir =  config['http']['static_dir']+ "/tmp/"