rearange files and updateing files
This commit is contained in:
1 parent
20acb4bc9f
commit
2de2c461e2
28 files changed
+285
-188
No files matched your search
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env python3
|
||||
from datetime import datetime, UTC
|
||||
|
||||
import package.database as database
|
||||
|
||||
DB = None
|
||||
|
||||
def has_no_timezone(dt_string: str) -> bool:
|
||||
try:
|
||||
# fromisoformat parses standard formats like YYYY-MM-DD HH:MM:SS
|
||||
dt = datetime.fromisoformat(dt_string)
|
||||
|
||||
# Check if tzinfo is completely missing OR if its offset is undefined
|
||||
return dt.tzinfo is None or dt.tzinfo.utcoffset(dt) is None
|
||||
except ValueError:
|
||||
print(f"Error: '{dt_string}' is not a valid date-time string.")
|
||||
return False
|
||||
|
||||
def fix_time():
|
||||
chats = DB.get_vods()
|
||||
#chats = DB.get_clips()
|
||||
|
||||
for chat in chats:
|
||||
(
|
||||
id,
|
||||
title,
|
||||
created_at,
|
||||
view_count,
|
||||
duration,
|
||||
url,
|
||||
thumbnail_url,
|
||||
game_id,
|
||||
game_name,
|
||||
stream_id,
|
||||
creator_name,
|
||||
clip_is,
|
||||
downloaded,
|
||||
uploaded_yt,
|
||||
uploaded_yt_chats,
|
||||
uploaded_yt_shorts,
|
||||
) = chat
|
||||
|
||||
if "T" in created_at:
|
||||
date_string = created_at.replace("T", " ")
|
||||
DB.update_datetime(id, date_string)
|
||||
|
||||
if has_no_timezone(created_at):
|
||||
dt_with_utc = datetime.fromisoformat(created_at).replace(tzinfo=UTC)
|
||||
date_string = dt_with_utc.isoformat().strftime('%Y-%m-%d %H:%M:%S %z')
|
||||
DB.update_datetime(id, date_string)
|
||||
|
||||
print("====================================================")
|
||||
print(f"✅ Processing: Times Fix.")
|
||||
print("====================================================")
|
||||
|
||||
def main():
|
||||
global DB
|
||||
DB = database.Database()
|
||||
|
||||
fix_time()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user