Skip to content

Commit

Permalink
fix:extract_resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
Guovin committed Feb 27, 2024
1 parent 29ebff9 commit cbf6d58
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from selenium.common.exceptions import NoSuchElementException
from bs4 import BeautifulSoup
from datetime import datetime
import re


class GetSource:
Expand Down Expand Up @@ -184,14 +185,19 @@ async def visitPage(self, channelItems):
reverse=True,
) # Sort by date
infoList = await self.compareSpeed(infoList) # Sort by speed

def extract_resolution(resolution_str):
numbers = re.findall(r"\d+x\d+", resolution_str)
if numbers:
width, height = map(int, numbers[0].split("x"))
return width * height
else:
return 0

infoList.sort(
key=lambda x: (
x[2] is not None,
(
int(x[2].split("x")[0]) * int(x[2].split("x")[1])
if x[2]
else 0
),
extract_resolution(x[2]) if x[2] else 0,
),
reverse=True,
) # Sort by resolution
Expand Down

0 comments on commit cbf6d58

Please sign in to comment.