selected videos added
Browse files- src/automation.py +3 -3
- src/video_downloader.py +7 -7
- video_analyser/modules/csv_writer.py +3 -3
src/automation.py
CHANGED
|
@@ -386,14 +386,14 @@ class ContentAutomation:
|
|
| 386 |
|
| 387 |
self.data_holder.visual_assets["all_videos"] = [
|
| 388 |
{
|
| 389 |
-
"url": row.get("
|
| 390 |
"local_path": VideoDownloader().download_video(
|
| 391 |
-
video_filename=row.get("
|
| 392 |
download_path=download_path
|
| 393 |
)
|
| 394 |
}
|
| 395 |
for _, row in self.asset_selector.video_library.iterrows()
|
| 396 |
-
if row.get("
|
| 397 |
]
|
| 398 |
else:
|
| 399 |
self.data_holder.visual_assets["all_videos"] = [
|
|
|
|
| 386 |
|
| 387 |
self.data_holder.visual_assets["all_videos"] = [
|
| 388 |
{
|
| 389 |
+
"url": row.get("VIDEO_FILENAME", "").strip(),
|
| 390 |
"local_path": VideoDownloader().download_video(
|
| 391 |
+
video_filename=row.get("VIDEO_FILENAME", "").strip(),
|
| 392 |
download_path=download_path
|
| 393 |
)
|
| 394 |
}
|
| 395 |
for _, row in self.asset_selector.video_library.iterrows()
|
| 396 |
+
if row.get("VIDEO_FILENAME", "").strip() in allowed_videos
|
| 397 |
]
|
| 398 |
else:
|
| 399 |
self.data_holder.visual_assets["all_videos"] = [
|
src/video_downloader.py
CHANGED
|
@@ -567,7 +567,7 @@ class VideoDownloader:
|
|
| 567 |
results = []
|
| 568 |
|
| 569 |
for video in self.video_library:
|
| 570 |
-
filename = video.get('
|
| 571 |
short_desc = video.get('short_description', '').lower()
|
| 572 |
desc = video.get('description', '').lower()
|
| 573 |
|
|
@@ -585,7 +585,7 @@ def add_folder_name_column(input_csv, output_csv, downloader):
|
|
| 585 |
with open(output_csv, newline="", encoding="utf-8") as f:
|
| 586 |
reader = csv.DictReader(f)
|
| 587 |
for row in reader:
|
| 588 |
-
processed.add(row["
|
| 589 |
|
| 590 |
with open(input_csv, newline="", encoding="utf-8") as infile, \
|
| 591 |
open(output_csv, "a", newline="", encoding="utf-8") as outfile:
|
|
@@ -598,7 +598,7 @@ def add_folder_name_column(input_csv, output_csv, downloader):
|
|
| 598 |
writer.writerow(["folder_name"] + reader.fieldnames)
|
| 599 |
|
| 600 |
for row in reader:
|
| 601 |
-
video_filename = row["
|
| 602 |
|
| 603 |
# Skip if already processed
|
| 604 |
if video_filename in processed:
|
|
@@ -622,9 +622,9 @@ def add_link_column(input_csv, output_csv, downloader):
|
|
| 622 |
if os.path.exists(output_csv):
|
| 623 |
with open(output_csv, newline="", encoding="utf-8") as f:
|
| 624 |
reader = csv.DictReader(f)
|
| 625 |
-
if reader.fieldnames and "
|
| 626 |
for row in reader:
|
| 627 |
-
processed.add(row["
|
| 628 |
|
| 629 |
# 2. Process the files
|
| 630 |
with open(input_csv, newline="", encoding="utf-8") as infile:
|
|
@@ -642,7 +642,7 @@ def add_link_column(input_csv, output_csv, downloader):
|
|
| 642 |
writer.writeheader()
|
| 643 |
|
| 644 |
for row in reader:
|
| 645 |
-
video_filename = row["
|
| 646 |
|
| 647 |
if video_filename in processed:
|
| 648 |
continue
|
|
@@ -715,7 +715,7 @@ if __name__ == "__main__":
|
|
| 715 |
# # Write CSV
|
| 716 |
# with open(output_csv, "w", newline="", encoding="utf-8") as f:
|
| 717 |
# writer = csv.writer(f)
|
| 718 |
-
# writer.writerow(["
|
| 719 |
# writer.writerows(rows)
|
| 720 |
|
| 721 |
# print(f"CSV created with {len(rows)} entries → {output_csv}")
|
|
|
|
| 567 |
results = []
|
| 568 |
|
| 569 |
for video in self.video_library:
|
| 570 |
+
filename = video.get('VIDEO_FILENAME', '').lower()
|
| 571 |
short_desc = video.get('short_description', '').lower()
|
| 572 |
desc = video.get('description', '').lower()
|
| 573 |
|
|
|
|
| 585 |
with open(output_csv, newline="", encoding="utf-8") as f:
|
| 586 |
reader = csv.DictReader(f)
|
| 587 |
for row in reader:
|
| 588 |
+
processed.add(row["VIDEO_FILENAME"])
|
| 589 |
|
| 590 |
with open(input_csv, newline="", encoding="utf-8") as infile, \
|
| 591 |
open(output_csv, "a", newline="", encoding="utf-8") as outfile:
|
|
|
|
| 598 |
writer.writerow(["folder_name"] + reader.fieldnames)
|
| 599 |
|
| 600 |
for row in reader:
|
| 601 |
+
video_filename = row["VIDEO_FILENAME"]
|
| 602 |
|
| 603 |
# Skip if already processed
|
| 604 |
if video_filename in processed:
|
|
|
|
| 622 |
if os.path.exists(output_csv):
|
| 623 |
with open(output_csv, newline="", encoding="utf-8") as f:
|
| 624 |
reader = csv.DictReader(f)
|
| 625 |
+
if reader.fieldnames and "VIDEO_FILENAME" in reader.fieldnames:
|
| 626 |
for row in reader:
|
| 627 |
+
processed.add(row["VIDEO_FILENAME"].split("/")[-1])
|
| 628 |
|
| 629 |
# 2. Process the files
|
| 630 |
with open(input_csv, newline="", encoding="utf-8") as infile:
|
|
|
|
| 642 |
writer.writeheader()
|
| 643 |
|
| 644 |
for row in reader:
|
| 645 |
+
video_filename = row["VIDEO_FILENAME"].split("/")[-1]
|
| 646 |
|
| 647 |
if video_filename in processed:
|
| 648 |
continue
|
|
|
|
| 715 |
# # Write CSV
|
| 716 |
# with open(output_csv, "w", newline="", encoding="utf-8") as f:
|
| 717 |
# writer = csv.writer(f)
|
| 718 |
+
# writer.writerow(["VIDEO_FILENAME"])
|
| 719 |
# writer.writerows(rows)
|
| 720 |
|
| 721 |
# print(f"CSV created with {len(rows)} entries → {output_csv}")
|
video_analyser/modules/csv_writer.py
CHANGED
|
@@ -17,7 +17,7 @@ class CSVWriter:
|
|
| 17 |
|
| 18 |
# Exact column order as specified
|
| 19 |
COLUMNS = [
|
| 20 |
-
'
|
| 21 |
'category',
|
| 22 |
'duration_seconds',
|
| 23 |
'short_description',
|
|
@@ -113,7 +113,7 @@ class CSVWriter:
|
|
| 113 |
assert isinstance(row['final_selection_score'], int)
|
| 114 |
|
| 115 |
# String fields
|
| 116 |
-
assert isinstance(row['
|
| 117 |
assert isinstance(row['category'], str)
|
| 118 |
assert isinstance(row['short_description'], str)
|
| 119 |
assert isinstance(row['description'], str)
|
|
@@ -148,7 +148,7 @@ class CSVWriter:
|
|
| 148 |
|
| 149 |
# Prepare row data
|
| 150 |
row = {
|
| 151 |
-
'
|
| 152 |
'category': ai_analysis.get('category', 'uncategorized'),
|
| 153 |
'duration_seconds': technical_analysis['duration_seconds'],
|
| 154 |
'short_description': ai_analysis.get('short_description', ''),
|
|
|
|
| 17 |
|
| 18 |
# Exact column order as specified
|
| 19 |
COLUMNS = [
|
| 20 |
+
'VIDEO_FILENAME',
|
| 21 |
'category',
|
| 22 |
'duration_seconds',
|
| 23 |
'short_description',
|
|
|
|
| 113 |
assert isinstance(row['final_selection_score'], int)
|
| 114 |
|
| 115 |
# String fields
|
| 116 |
+
assert isinstance(row['VIDEO_FILENAME'], str)
|
| 117 |
assert isinstance(row['category'], str)
|
| 118 |
assert isinstance(row['short_description'], str)
|
| 119 |
assert isinstance(row['description'], str)
|
|
|
|
| 148 |
|
| 149 |
# Prepare row data
|
| 150 |
row = {
|
| 151 |
+
'VIDEO_FILENAME': os.path.basename(video_path),
|
| 152 |
'category': ai_analysis.get('category', 'uncategorized'),
|
| 153 |
'duration_seconds': technical_analysis['duration_seconds'],
|
| 154 |
'short_description': ai_analysis.get('short_description', ''),
|