Jeffgold commited on
Commit
b12aa85
·
1 Parent(s): 4bec373

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -85,7 +85,7 @@ def create_master_playlist(output_paths, input_filename):
85
  with open(path, 'r') as playlist_file:
86
  content = playlist_file.readlines()
87
  # replace .ts extension with complete URL pointing to the TS segments on S3
88
- content = [f"https://{AWS_S3_BUCKET}.s3.amazonaws.com/{input_filename}/{res}/{line}" if line.endswith('.ts\n') else line for line in content]
89
  f.writelines(content)
90
  return master_playlist_path
91
 
@@ -135,14 +135,14 @@ def convert_video(video_file, quality, aspect_ratio, video_url):
135
  output_links = []
136
  for path in output_paths:
137
  res_folder = Path(path).stem.split("_")[1] if "_" in Path(path).stem else ""
138
- s3_path = f"s3://{AWS_S3_BUCKET}/{Path(input_path).stem}/{res_folder}/{Path(path).name}"
139
  upload_file_to_s3(path, s3_path)
140
- output_links.append(f'<a href="https://s3-us-east-1.amazonaws.com/{AWS_S3_BUCKET}/{Path(input_path).stem}/{res_folder}/{Path(path).name}" target="_blank">Download {Path(path).stem}</a>')
141
 
142
  # upload ts files to s3
143
  for path in output_dir.glob(f"{Path(input_path).stem}_*p_*.ts"):
144
  res_folder = Path(path).stem.split("_")[1]
145
- s3_path = f"s3://{AWS_S3_BUCKET}/{Path(input_path).stem}/{res_folder}/{Path(path).name}"
146
  upload_file_to_s3(path, s3_path)
147
 
148
  output_html = "<br>".join(output_links)
 
85
  with open(path, 'r') as playlist_file:
86
  content = playlist_file.readlines()
87
  # replace .ts extension with complete URL pointing to the TS segments on S3
88
+ content = [f"https://{AWS_S3_BUCKET}.s3.amazonaws.com/{quote_plus(input_filename)}/{res}/{quote_plus(line.rstrip())}\n" if line.endswith('.ts\n') else line for line in content]
89
  f.writelines(content)
90
  return master_playlist_path
91
 
 
135
  output_links = []
136
  for path in output_paths:
137
  res_folder = Path(path).stem.split("_")[1] if "_" in Path(path).stem else ""
138
+ s3_path = f"s3://{AWS_S3_BUCKET}/{quote_plus(Path(input_path).stem)}/{res_folder}/{quote_plus(Path(path).name)}"
139
  upload_file_to_s3(path, s3_path)
140
+ output_links.append(f'<a href="https://{AWS_S3_BUCKET}.s3.amazonaws.com/{quote_plus(Path(input_path).stem)}/{res_folder}/{quote_plus(Path(path).name)}" target="_blank">Download {Path(path).stem}</a>')
141
 
142
  # upload ts files to s3
143
  for path in output_dir.glob(f"{Path(input_path).stem}_*p_*.ts"):
144
  res_folder = Path(path).stem.split("_")[1]
145
+ s3_path = f"s3://{AWS_S3_BUCKET}/{quote_plus(Path(input_path).stem)}/{res_folder}/{quote_plus(Path(path).name)}"
146
  upload_file_to_s3(path, s3_path)
147
 
148
  output_html = "<br>".join(output_links)