-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvkd_gui_interface.py
More file actions
executable file
·106 lines (86 loc) · 4.03 KB
/
vkd_gui_interface.py
File metadata and controls
executable file
·106 lines (86 loc) · 4.03 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# -*- coding: utf-8 -*-
from PyQt4.QtCore import QUrl, SIGNAL
from PyQt4.QtGui import *
import os
import sys
from lastfmApi import lfmAPI
import ConfigParser
from vkdtools import tomin, initVk
import vkd3ui
class MainWindow(QDialog, vkd3ui.Ui_Dialog):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.setupUi(self)
self.lfm = lfmAPI("f3d8fbacbda2a35bfa855ef52052ca25") # Init Last.FM Api
self.status = {'artist' : '',
'album' : '',
'tags' : ''}
self.runDir = os.getcwdu()
config = ConfigParser.ConfigParser()
try:
config.read(os.path.join(self.runDir, 'vkdconfig.ini'))
self.login = config.get('vkuser', 'login')
self.password = config.get('vkuser', 'pass')
self.vkLoginLine.setText(self.login)
self.vkPassLine.setText(self.password)
except:
print 'Fail'
self.connect(self.searchButton, SIGNAL('clicked()'), self.fillArtists)
self.connect(self.artistList, SIGNAL('itemDoubleClicked(QListWidgetItem *)'), self.ArtistListClick)
self.connect(self.albumsList, SIGNAL('itemDoubleClicked(QListWidgetItem *)'), self.AlbumsListClick)
self.connect(self.downloadChekedAlbums, SIGNAL('clicked()'), self.downloadCheckedAlbumsGo)
self.connect(self.trackList, SIGNAL('itemDoubleClicked(QListWidgetItem *)'), self.TrackListClick)
self.connect(self.vkLoginButton, SIGNAL('clicked()'), self.vkLogin)
def vkLogin(self):
login = self.vkLoginLine.text()
password = self.vkPassLine.text()
if login and password:
self.br = initVk(login, password)
self.label_4.setText(u"Учетная запись [Вконтакте] - <font color=green>Вход выполнен</font>")
else:
QMessageBox.warning(self, 'VKD3', 'VK Login Error')
def fillArtists(self):
if self.lineEdit.text():
self.artistList.clear()
self.artistList.addItems(self.lfm.artist_search(unicode(self.lineEdit.text())))
else:
QMessageBox.warning(self, 'VKD3', 'Search request is Empty')
def ArtistListClick(self, item):
selectedArtist = unicode(item.text())
self.albumsList.clear()
self.albumsList.addItems(self.lfm.getTopAlbums(selectedArtist))
self.status['tags'] = self.lfm.getTopTags(selectedArtist)
self.status['artist'] = selectedArtist
self.artistLabel.setText(selectedArtist)
def AlbumsListClick(self, item):
self.downloadAlbumButton.setEnabled(True)
self.downloadCheckedTracksButton.setEnabled(True)
self.downloadAlbumartButton.setEnabled(True)
self.playListGetAlbumButton.setEnabled(True)
self.trackList.clear()
selectedAlbum = unicode(item.text())
covers = self.lfm.getAlbumCovers(self.status['artist'], selectedAlbum)
tracks, release_date = self.lfm.getAlbumInfo(self.status['artist'], selectedAlbum)
self.albumArtView.load(QUrl(covers['large']))
self.AlbumLabel.setText(selectedAlbum)
self.trackCountLabel.setText(str(len(tracks)))
if release_date:
release_Year = release_date.year
else:
release_Year = ''
self.status['year'] = release_Year
self.trackCountLabel_2.setText(str(release_Year))
self.dict_tracks = {}
for track in tracks:
trackListItem = '[%s] %s [%s]' % (track[0], track[1], tomin(track[2]))
self.trackList.addItem(trackListItem)
self.dict_tracks[trackListItem] = track
def downloadCheckedAlbumsGo(self):
selectedAlbums = self.albumsList.selectedItems()
def TrackListClick(self, item):
selectedTrack = unicode(item.text())
selectedTrackDetailed = self.dict_tracks[selectedTrack]
app = QApplication(sys.argv)
form = MainWindow()
form.show()
sys.exit(app.exec_())