Browse Source

add config support

master
Shokara Kou 6 months ago
parent
commit
90d2d1c268
  1. 1
      .gitignore
  2. 6
      config.txt.example
  3. 21
      icedj.py

1
.gitignore vendored

@ -1,2 +1,3 @@
icedj-files
__pycache__
config.txt

6
config.txt.example

@ -0,0 +1,6 @@
[IceDJ-shout]
host = 127.0.0.1
port = 8000
user = source
password = hackme
mount = /icedj

21
icedj.py

@ -1,11 +1,21 @@
#!/usr/bin/env python3
import pathlib, os, sys, traceback
import pathlib, os, sys, traceback, configparser
from yt_dlp import YoutubeDL
from shout import Shout
class IceDJ:
# TODO: use a config file
def __init__(self):
config = configparser.ConfigParser()
config.read('config.txt')
cfgShout = config['IceDJ-shout']
self.shout = Shout()
self.shout.host = cfgShout['host']
self.shout.port = int(cfgShout['port'])
self.shout.user = cfgShout['user']
self.shout.password = cfgShout['password']
self.shout.mount = cfgShout['mount']
self.ydl_opts = {
'format': 'bestaudio',
'postprocessors': [{
@ -18,13 +28,6 @@ class IceDJ:
pathlib.Path(self.directory).mkdir(parents=True, exist_ok=True)
os.chdir(self.directory)
self.shout = Shout()
self.shout.host = '127.0.0.1'
self.shout.port = 8000
self.shout.user = 'source'
self.shout.password = 'hackme'
self.shout.mount = '/icedj'
# TODO: check if url is valid
# downloads a url to a file and returns it's filename
def download(self, url):

Loading…
Cancel
Save