This repository has been archived by the owner on Oct 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMusic.py
119 lines (98 loc) · 3.96 KB
/
Music.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
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
107
108
109
110
111
112
113
114
115
116
117
118
# Author: Dennis Lutter <[email protected]>
# URL: https://github.com/lad1337/XDM-main-plugin-repo/
#
# This file is part of a XDM plugin.
#
# XDM plugin.
# Copyright (C) 2013 Dennis Lutter
#
# This plugin is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This plugin is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
from xdm.plugins import *
from xdm.helper import replaceUmlaute
class Song(object):
position = 0
title = ''
lenght = 0.0
_orderBy = 'position'
def getTemplate(self):
return '<li class="bORw"><span class="songPosition bORw">{{this.position}}</span><span class="songTitle bORw">{{this.title}}</span><span class="length bORw">{{this.length}}</span></li>'
class Album(object):
name = ''
year = 0
cover_image = ''
_orderBy = 'year'
def getTemplate(self):
return """<div class="Album {{statusCssClass}}" data-id="{{this.id}}">
<img src="{{this.cover_image}}">
<p>{{name}}<br><span class="artistName">{{this.parent.name}}</span></p>
<div class="indi">▲</div>
<div class="songs">
<div class="info">
<strong class="bORw name">{{name}}</strong>{{actionButtons}}{{infoButtons}}{{statusSelect}}
<p class="bORw">{{this.parent.name}} ({{this.year}})</p>
</div>
<ol class="bORw"></ol>
</div>
</div>
"""
def getSearchTerms(self):
return ['%s %s' % (self.parent.name, self.name)]
def getName(self):
return self.name
class Artist(object):
name = ''
bio = ''
_orderBy = 'name'
def getName(self):
return self.name
def getTemplate(self):
return '{{children}}'
class Music(MediaTypeManager):
version = "0.5"
xdm_version = (0, 5, 14)
single = True
_config = {'enabled': True}
config_meta = {'plugin_desc': 'Music support. Good for Albums'}
order = (Artist, Album, Song)
download = Album
identifier = 'de.lad1337.music'
addConfig = {}
addConfig[Downloader] = [{'type':'category', 'default': None, 'prefix': 'Category for', 'sufix': 'Music'}]
addConfig[Indexer] = [{'type':'category', 'default': None, 'prefix': 'Category for', 'sufix': 'Music'}]
addConfig[PostProcessor] = [{'type':'path', 'default': None, 'prefix': 'Final path for', 'sufix': 'Music'}]
def makeReal(self, album, status):
oldArtist = album.parent
for artist in list(Element.select().where(Element.type == oldArtist.type,
Element.mediaType == self.mt,
Element.parent == self.root)):
if artist.getField('id') == oldArtist.getField('id'):
album.parent = artist
album.status = status
album.save()
album.downloadImages()
return True
else:
log('We dont have the artist so we copy that')
newArtist = album.parent.copy()
newArtist.parent = self.root
newArtist.save()
album.parent = newArtist
album.status = status
album.save()
for song in list(album.children):
song.save()
album.downloadImages()
return True
def headInject(self):
return self._defaultHeadInject()