Parcourir la source

flush stdout

master
Andreas Demmelbauer il y a 4 ans
Parent
révision
4da874d8f9
1 fichiers modifiés avec 13 ajouts et 0 suppressions
  1. +13
    -0
      demotape.py

+ 13
- 0
demotape.py Voir le fichier

@@ -18,12 +18,15 @@ try:
if sys.argv[1] and os.path.exists(sys.argv[1]):
ROOT_PATH = sys.argv[1]
print('Root path for downloaded streams: ' + ROOT_PATH)
sys.stdout.flush()
else:
print('destination path does not exist')
sys.stdout.flush()
sys.exit()
except IndexError:
print('Script needs a valid destination path for recorded videos as argument')
print('For example: \ndemotape.py /path/to/videos')
sys.stdout.flush()
sys.exit()


@@ -57,6 +60,7 @@ def check_stream(url):
return False
except (ValueError, KeyError):
print('some connection error or so')
sys.stdout.flush()



@@ -64,19 +68,24 @@ class MyLogger(object):
def debug(self, msg):
#pass
print(msg)
sys.stdout.flush()


def warning(self, msg):
#pass
print(msg)
sys.stdout.flush()

def error(self, msg):
print(msg)
sys.stdout.flush()


def my_ytdl_hook(d):
if d['status'] == 'finished':
print('Done downloading!')
print(d)
sys.stdout.flush()


def download_stream(channel):
@@ -118,14 +127,17 @@ def process_channel(channel):
#print('checking ' + channel['name'])
if check_stream(channel['url']):
print(channel['name'] + ': found stream! Downloading ...')
sys.stdout.flush()
download_stream(channel)
else:
print(channel['name'] + ': no stream')
sys.stdout.flush()
# wait between checks
waitingtime = random.randint(20,30)
time.sleep(waitingtime)

print('end processing ' + channel['name'] + ' ... (shouldn\'t happen!)')
sys.stdout.flush()



@@ -147,6 +159,7 @@ def main():


print('end main (this shouldn\'t happen!)')
sys.stdout.flush()


main()


Chargement…
Annuler
Enregistrer