Пример #1
0
def clean_str(s):
    return s.strip().lower()

def clean_filename(s):
    return s.replace('/', '').replace('\\', '').replace('"', "'").replace(":", "-").replace('|', '-').replace('*', '').replace('?', '')

def make_file_name(audio):
    return folder + clean_filename(unicode(audio['artist']))+ ' - ' + clean_filename(unicode(audio['title'])) + ".mp3"

print "folder to save in:"
folder = raw_input()
print "audio to grab:"
song_name = raw_input().lower()
print "okee-dokee, fetching ur music"
options = []
for audio in crawler.get_audio('85201601'):
    if len(song_name) == 0 or clean_str(audio['artist']).find(song_name) > -1 or clean_str(audio['title']).find(song_name) > -1:
        options.append(audio)
print "possible options:"
for index, option in enumerate(options):
    print "%d. %s - %s" % (index + 1, option['artist'], option['title'])
chosen_s = raw_input().lower()
chosen_options = set()

for opt in chosen_s.split(","):
    if opt == "*":
        chosen_options = set(range(len(options)))
        break
    else:
        if opt.find("-") > -1:
            pieces = opt.split("-")
Пример #2
0
    except KeyError:
        pass
print "tagged!"

credentials = VKCredentialsCollection(
    credentials=[
        {
            "api_id": "2888416",
            "viewer_id": "85201601",
            "secret": "fee76f3fb9",
            "sid": "03a7cb69570208eea0427eaaafda3c231f058192fe8f92a6f794eac08b1a2b",
        }
    ]
)
crawler = VKCrawler(credentials)
audios = [audio for audio in crawler.get_audio("85201601")]
for audio in audios:
    if not audio["aid"] in cache:
        print 'downloading "%s"' % audio["title"]
        url = audio["url"]
        f = urllib2.urlopen(url)
        data = f.read()
        file_name = make_file_name(audio)
        save_file = open(file_name, "wb")
        save_file.write(data)
        save_file = MP3(file_name)
        save_file["TSRC"] = TSRC(encoding=3, text=[str(audio["aid"])])
        save_file.save()
    else:
        new_name = make_file_name(audio)
        old_name = cache[audio["aid"]]