Skip to content

Commit

Permalink
final cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mjishnu committed Jan 21, 2024
1 parent fdd2484 commit 4754c71
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions pypdl/utls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@


def get_filename(url: str, headers: Dict) -> str:
content_disposition = headers.get("Content-Disposition")
content_disposition = headers.get("Content-Disposition", None)

if content_disposition is not None and "filename=" in content_disposition:
if content_disposition and "filename=" in content_disposition:
filename_start = content_disposition.index("filename=") + len("filename=")
filename = content_disposition[filename_start:] # Get name from headers
filename = filename.strip('"')
return unquote(filename) # Decode URL encodings
else:
return unquote(urlparse(url).path.split("/")[-1]) # Generate name from url
filename = urlparse(url).path.split("/")[-1] # Generate name from url

return unquote(filename) # Decode URL encodings


def timestring(sec: int) -> str:
Expand Down Expand Up @@ -63,9 +64,7 @@ def create_segment_table(
)
)

dic = {}
dic["url"] = url
dic["segments"] = segments
dic = {"url": url, "segments": segments}
partition_size = size / segments
for segment in range(segments):
start = int(partition_size * segment)
Expand Down

0 comments on commit 4754c71

Please sign in to comment.