-
Notifications
You must be signed in to change notification settings - Fork 2
/
skinner.py
executable file
·70 lines (57 loc) · 2.19 KB
/
skinner.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
#!/usr/bin/env python3
# Jellyfin-seymour
# Copyright (C) 2019 Red_M ( http://bitbucket.com/Red_M )
# This program 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 2 of the License, or
# (at your option) any later version.
# This program 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, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import os
import sys
import json
class skinner(object):
def __init__(self):
self.config = self.load_config()
f = open('template.css','r')
self.template = f.read()
f.close()
f = open('transparent_header.css','r')
self.transparent_header = f.read()
f.close()
self.skin()
def debug_print(self, text):
print(text)
def load_config(self):
f = open('config.json','r')
conf = json.load(f)
f.close()
return(conf)
def replace_into_template(self, template, theme_config):
out = str(template)
for key in theme_config:
out = out.replace('###'+key+'###',theme_config[key])
return(out)
def skin(self):
selected_theme = self.config['selected_theme']
if selected_theme in self.config['themes']:
theme_config = self.config['themes'][selected_theme]
f = open('output.css','w')
output = self.replace_into_template(self.template, theme_config)
if self.config['transparent_header']:
output = output+self.replace_into_template(self.transparent_header, theme_config)
f.write(output)
self.debug_print('Done!')
else:
self.debug_print('Bad theme selected.')
if 'f' in locals():
f.close()
def main():
a = skinner()
if __name__=='__main__':
main()