Commit 95d2639e authored by liyang's avatar liyang

fix:爬取youtube

parent 88e54721
...@@ -21,20 +21,20 @@ def convert_string_to_time(string): ...@@ -21,20 +21,20 @@ def convert_string_to_time(string):
if "天前" in string: if "天前" in string:
days = int(string.split("天前")[0]) days = int(string.split("天前")[0])
converted_time = current_time - relativedelta(days=days) converted_time = current_time - timedelta(days=days)
elif "周前" in string: elif "周前" in string:
weeks = int(string.split("周前")[0]) weeks = int(string.split("周前")[0])
converted_time = current_time - relativedelta(weeks=weeks) converted_time = current_time - timedelta(weeks=weeks)
elif "月前" in string: elif "月前" in string:
months = int(string.split("月前")[0]) months = int(string.split("月前")[0])
converted_time = current_time - relativedelta(months=months) converted_time = current_time - timedelta(days=months * 30)
elif "年前" in string: elif "年前" in string:
years = int(string.split("年前")[0]) years = int(string.split("年前")[0])
converted_time = current_time - relativedelta(years=years) converted_time = current_time - timedelta(days=years * 365)
else: else:
raise ValueError("Invalid string format") raise ValueError("Invalid string format")
timestamp = converted_time.timestamp() timestamp = int(converted_time.timestamp())
return timestamp return timestamp
def convert_to_traditional(simplified_text): def convert_to_traditional(simplified_text):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment