From bcb7d150ae3b4cf3f03e3874e207cd8835cfb2ac Mon Sep 17 00:00:00 2001 From: Gabriel Bellon Date: Mon, 4 Oct 2021 21:09:00 -0300 Subject: [PATCH] escolhendo videos para download --- Makefile | 9 +++------ streamyard_down/streamyard.py | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index adc50b1..5266cbf 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,6 @@ format: - black . - isort . + black streamyard_down/* + isort streamyard_down/* install: - pip install -r requirements.txt - -run: - python src/down_streamyard.py \ No newline at end of file + pip install -r requirements.txt \ No newline at end of file diff --git a/streamyard_down/streamyard.py b/streamyard_down/streamyard.py index c76a8d5..ec12bcd 100644 --- a/streamyard_down/streamyard.py +++ b/streamyard_down/streamyard.py @@ -164,6 +164,7 @@ def create_download_list(self): broadcast_to_download.append( dict( stream_id=broadcast.get("id"), + stream_date=broadcast.get("date"), file_name=file_name, audio_filename=f"{file_name}.mp3", video_filename=f"{file_name}.mp4", @@ -239,7 +240,38 @@ def download_broadcast(self, stream_info): def start_download(self): self.login() - self.dowload(self.create_download_list()) + download_list = self.create_download_list() + options = "" + for index, item in enumerate(download_list): + options += f"** ID:{index} - STREAM:{item.get('file_name')} - DATE:{item.get('stream_date')}\n" + + message = f""" + ############################ + LISTANDO STREAMS ENTRE OS DIAS {self.start_date.strftime('%Y-%m-%d') } e {self.end_date.strftime('%Y-%m-%d') } + ESCOLHA QUAIS ARQUIVOS DESEJA REALIZAR O DOWNLOAD INFORMANDO O IDs SEPARADOS POR VIRGULA(,) + EXEMPLOS: + 0,1,2,3 Para baixar os IDs 0,1,2,3 + 1 - Para baixar apenas o ID 1 + IDs para donwload: + + ##### LISTA DE STREAMS #####: + {options} + + Selecione os IDs: + """ + ids = input(message) + + to_download=[] + escolhas="" + for id in ids.split(','): + + data = download_list[int(id)] + escolhas += f"** ID:{id} - STREAM:{data.get('file_name')} - DATE:{data.get('stream_date')}\n" + to_download.append(data) + + print(f"OS SEGUINTES IDs serĂ£o baixados {ids}\n{escolhas}") + + self.dowload(to_download) def send_to_s3(self, sent_file): key = "{}/{}".format(cfg.S3_PREFIX, os.path.basename(sent_file))