/
song.py
50 lines (41 loc) · 1.1 KB
/
song.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from DB import *
from config import *
class Song():
querySongSelect = """
SELECT id, artist, title, path
FROM songs
WHERE id = %s"""
def __init__(self, i_song=0, config=None):
self.id = 0
self.artist = False;
self.title = False;
self.path = False;
if config:
self.Config = config
else:
self.Config = Config()
if i_song:
self.open(i_song)
def open(self, i_song):
try:
db = conn.cursor()
except NameError:
conn = DB()
db = conn.cursor()
db.execute(self.querySongSelect, (i_song))
row = db.fetchone()
try:
self.id = i_song
self.artist = row[1]
self.title = row[2]
self.path = row[3]
except:
self.id = 0
self.artist = False
self.title = False
self.path = False
try:
self.artist = self.artist.decode('UTF-8')
self.title = self.title.decode('UTF-8')
except:
pass