-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextract_create_date.py
More file actions
44 lines (37 loc) · 1.28 KB
/
extract_create_date.py
File metadata and controls
44 lines (37 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# -*- coding: utf-8 -*-
import os
import sys
from datetime import datetime, timezone
from zoneinfo import ZoneInfo
from pathlib import Path
from dotenv import load_dotenv
from utils import get_data_from_google_sheet
def get_mtime(video_path: Path) -> str | None:
try:
mtime = video_path.stat().st_mtime
tz_mayotte = ZoneInfo("Indian/Mayotte")
return datetime.fromtimestamp(mtime, tz=tz_mayotte).strftime("%d/%m/%Y %H:%M:%S")
except OSError:
return None
def main():
load_dotenv()
google_sheet_id = os.getenv("GG_SHEET_ID")
if google_sheet_id is None:
print("GG_SHEET_ID manquant dans le fichier .env")
sys.exit(1)
root_data_path = os.getenv("ROOT_DATA_PATH")
if root_data_path is None:
print("ROOT_DATA_PATH manquant dans le fichier .env")
sys.exit(1)
root_data_path = Path(root_data_path)
CSV_DATA = get_data_from_google_sheet(google_sheet_id)
for index, ligne in enumerate(CSV_DATA):
numero = ligne.get("NUMERO", "")
if not str(numero).strip().lstrip("-").isdigit():
continue
video_path = root_data_path / ligne["VIDEO_PATH"]
#print(video_path)
create_date = get_mtime(video_path)
print(create_date)
if __name__ == "__main__":
main()