|
@@ -15,11 +15,13 @@
|
15
|
15
|
# You should have received a copy of the GNU General Public License
|
16
|
16
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
17
|
|
|
18
|
+import time
|
18
|
19
|
import requests
|
19
|
20
|
import configparser
|
20
|
21
|
from argparse import ArgumentParser
|
21
|
22
|
|
22
|
23
|
API_URL = 'http://www.fipradio.fr/livemeta/7'
|
|
24
|
+DEBUG = False
|
23
|
25
|
|
24
|
26
|
|
25
|
27
|
def main():
|
|
@@ -39,9 +41,10 @@ def main():
|
39
|
41
|
default='conf.ini',
|
40
|
42
|
help="Configuration file")
|
41
|
43
|
args = parser.parse_args()
|
|
44
|
+ conf = configparser.ConfigParser()
|
|
45
|
+ conf.read(args.conf)
|
|
46
|
+ globals()['DEBUG'] = conf.get('conf', 'debug', fallback="False").lower() == 'true'
|
42
|
47
|
if args.update:
|
43
|
|
- conf = configparser.ConfigParser()
|
44
|
|
- conf.read(args.conf)
|
45
|
48
|
host = conf.get('conf', 'host', fallback='127.0.0.1:8000')
|
46
|
49
|
mount = conf.get('conf', 'mount', fallback='/example.ogg')
|
47
|
50
|
login = conf.get('conf', 'login', fallback='admin')
|
|
@@ -89,12 +92,15 @@ Album :\t\t{album}
|
89
|
92
|
Visual :\t{image}
|
90
|
93
|
Youtube :\t{youtube}
|
91
|
94
|
"""
|
92
|
|
- return infos.format(
|
|
95
|
+ res = infos.format(
|
93
|
96
|
title=item['title'].title(),
|
94
|
97
|
author=item['authors'].title(),
|
95
|
98
|
album=item['titreAlbum'].title(),
|
96
|
99
|
image=item['visual'],
|
97
|
100
|
youtube=item['lienYoutube'])
|
|
101
|
+ if globals()['DEBUG']:
|
|
102
|
+ res = "[debug mode]\n"+res
|
|
103
|
+ return res
|
98
|
104
|
|
99
|
105
|
|
100
|
106
|
def icecast_infos():
|
|
@@ -106,6 +112,8 @@ def icecast_infos():
|
106
|
112
|
infos += ' - '+item['authors'].title()
|
107
|
113
|
if len(item['titreAlbum']):
|
108
|
114
|
infos += ' ('+item['titreAlbum'].title()+')'
|
|
115
|
+ if globals()['DEBUG']:
|
|
116
|
+ infos = infos + str(time.time())
|
109
|
117
|
return infos
|
110
|
118
|
|
111
|
119
|
|