Browse Source

flush stdout

master
Andreas Demmelbauer 4 years ago
parent
commit
4da874d8f9
1 changed files with 13 additions and 0 deletions
  1. +13
    -0
      demotape.py

+ 13
- 0
demotape.py View File

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




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






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



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


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




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




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


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






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




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




main() main()


Loading…
Cancel
Save