Iammcqwory commited on
Commit
029d14e
·
verified ·
1 Parent(s): 691060c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -10
app.py CHANGED
@@ -37,26 +37,28 @@ class VideoDownloader:
37
  """Process and return streams information"""
38
  try:
39
  if stream_type == 'video':
40
- # Get all progressive MP4 streams
41
- all_streams = yt.streams.filter(progressive=True, file_extension='mp4').all()
42
  # Extract unique resolutions
43
  resolutions = []
44
  seen = set()
45
  for stream in all_streams:
46
- if stream.resolution and stream.resolution not in seen:
47
- resolutions.append(stream.resolution)
48
- seen.add(stream.resolution)
 
49
  return all_streams, sorted(resolutions, reverse=True), yt.title
50
  else:
51
- # Get all audio streams
52
- all_streams = yt.streams.filter(only_audio=True).all()
53
  # Extract unique bitrates
54
  bitrates = []
55
  seen = set()
56
  for stream in all_streams:
57
- if stream.abr and stream.abr not in seen:
58
- bitrates.append(stream.abr)
59
- seen.add(stream.abr)
 
60
  return all_streams, sorted(bitrates, reverse=True), yt.title
61
  except Exception as e:
62
  logger.error(f"Error processing streams: {e}")
 
37
  """Process and return streams information"""
38
  try:
39
  if stream_type == 'video':
40
+ # Convert streams to list first
41
+ all_streams = list(yt.streams.filter(progressive=True, file_extension='mp4'))
42
  # Extract unique resolutions
43
  resolutions = []
44
  seen = set()
45
  for stream in all_streams:
46
+ res = getattr(stream, 'resolution', None)
47
+ if res and res not in seen:
48
+ resolutions.append(res)
49
+ seen.add(res)
50
  return all_streams, sorted(resolutions, reverse=True), yt.title
51
  else:
52
+ # Convert streams to list first
53
+ all_streams = list(yt.streams.filter(only_audio=True))
54
  # Extract unique bitrates
55
  bitrates = []
56
  seen = set()
57
  for stream in all_streams:
58
+ abr = getattr(stream, 'abr', None)
59
+ if abr and abr not in seen:
60
+ bitrates.append(abr)
61
+ seen.add(abr)
62
  return all_streams, sorted(bitrates, reverse=True), yt.title
63
  except Exception as e:
64
  logger.error(f"Error processing streams: {e}")