Browse Source

move stdin example to cli.py

master
Shokara Kou 6 months ago
parent
commit
3ec0dda401
  1. 3
      .gitignore
  2. 11
      cli.py
  3. 13
      icedj.py

3
.gitignore vendored

@ -1 +1,2 @@
icedj-files
icedj-files
__pycache__

11
cli.py

@ -0,0 +1,11 @@
#!/usr/bin/env python3
import sys
from icedj import IceDJ
dj = IceDJ()
for line in sys.stdin:
print(line)
file = dj.download(line)
if file != None:
dj.stream(file)

13
icedj.py

@ -23,14 +23,14 @@ class IceDJ:
self.shout.port = 8000
self.shout.user = 'source'
self.shout.password = 'hackme'
self.shout.mount = '/stream'
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):
try:
with YoutubeDL(self.ydl_opts) as ydl:
url = line.strip()
url = url.strip()
info = ydl.extract_info(url, download=False)
print(f"Downloading {info['title']} by {info['uploader']}")
@ -72,11 +72,4 @@ class IceDJ:
f.close()
self.shout.close()
print(f'Finished streaming file: {filename}')
dj = IceDJ()
for line in sys.stdin:
file = dj.download(line)
if file != None:
dj.stream(file)
print(f'Finished streaming file: {filename}')
Loading…
Cancel
Save