Skip to content

Instantly share code, notes, and snippets.

@zhangolve
Last active August 9, 2016 03:03
Show Gist options
  • Save zhangolve/2a28fdf189bcb950f7a9d216dc292be8 to your computer and use it in GitHub Desktop.
Save zhangolve/2a28fdf189bcb950f7a9d216dc292be8 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 09 08:25:23 2016
@author: zhangolve zhangolve@gmail.com
"""
import re
fileHandle = open ( 'spotify.txt' )
content=fileHandle.read()
fileHandle.close()
song = re.compile(' "Track Name": "(.*?)"')
artist = re.compile(' "Artist Name": "(.*?)"')
songs = song.findall(content)
artists=artist.findall(content)
ListName='Weekly Discovery' # you can change the ListName to anyone
f=open('weekly.kgl','a') # this is the final kugou song list you don't need to create it manually.
f.writelines('<?xml version="1.0" encoding="windows-1252"?>'+'\n'+'<List ListName="'+ListName+'">')
for i in range(len(songs)):
f=open('weekly.kgl','a')
f.writelines('<File>')
f.writelines('<FileName> ')
f.writelines(artists[i]+'-'+songs[i]+'</FileName>')
f.writelines('</File>')
f.writelines('\n')
print 'succeed'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment