Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

list choise #11

Merged
merged 3 commits into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions streamyard_down/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
required=True,
)

parser.add_argument(
"-lc",
"--list_choise",
action="store_true",
help="Show a list of streamns to dowload",
dest="list_choise",
)

parser.add_argument(
"-p",
"--path",
Expand Down
5 changes: 0 additions & 5 deletions streamyard_down/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,3 @@
DOWNLOAD_URL = "https://streamyard.com/api/broadcasts/{stream_id}/vod_download_urls"
LIST_PAST_URL = "https://streamyard.com/api/broadcasts?limit=99&isComplete=true"
BROAD_CAST_URL = "https://streamyard.com/api/broadcasts/"


S3_PREFIX = config("S3_PREFIX")
S3_BUCKET = config("S3_BUCKET")
EMAIL = config("EMAIL")
55 changes: 30 additions & 25 deletions streamyard_down/streamyard.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def __init__(
threads=1,
chuck_size=1024,
upload=False,
list_choise=False,
):
self.email = email
self.path = path
Expand All @@ -35,6 +36,7 @@ def __init__(
self.start_date = start_date
self.end_date = end_date
self.request_session = self.create_session()
self.list_choise = list_choise

def create_session(self):
logger.info("Criando Sessão")
Expand Down Expand Up @@ -245,32 +247,35 @@ def start_download(self):
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}")

if self.list_choise:
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}")
else:
to_download = download_list

self.dowload(to_download)

def send_to_s3(self, sent_file):
Expand Down