Commit graph

170 commits

Author SHA1 Message Date
nickviljoen
37097d2148 Enhancement: Template-based folder-only mode and EOL workflow
Folder-only mode (-N flag) now uses asset_representation_template.json
as the base for all metadata fields, matching the exact structure the DAM
API expects. Also adds EOL (External Legal Opinion) as a new asset type
with field overrides (Agency=-, ProdCompany=-, Languages=Global,
IPRights=Yes, Licensing=No, no validity dates).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 15:52:22 +02:00
nickviljoen
2ec22c62a5 Fix: Folder-only mode metadata format for PROD DAM compatibility
Folder-only mode (-N suffix files) was sending simplified metadata that
PROD DAM rejected with "unmarshalling parameter" error. Updated to use
DomainValue format for domained fields, correct asset type field ID
(FERRERO.FIELD.MKTG.ASSET TYPE), asset type code mapping (e.g. SND→sound),
validity dates, and forced values from config.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 12:24:44 +02:00
nickviljoen
7412019053 Update: Move ELO to asset type, add VOD social media code, remove OLV asset type
- ELO (External Legal Opinion) is now a standard asset type instead of a separate
  document type flag in the filename. Field overrides (Agency, Prod Company,
  Languages) still trigger when ELO is selected as asset type.
- Added VOD to social media platform codes
- Removed OLV from asset type mappings
- Renamed document_type_overrides to asset_type_overrides throughout

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-16 21:21:44 +02:00
nickviljoen
7deb9db0a5 Fix: Update MAIN_LANGUAGES values array for tabular fields in DAM upload
The filename_updates logic was only updating field['value'] (singular) but for
tabular fields like MAIN_LANGUAGES, the DAM reads from field['values'] (plural
array). This caused the master's original language (e.g. "Global") to persist
instead of the correct language from the filename (e.g. "PL").

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 17:27:09 +02:00
nickviljoen
ad714d4b14 Revert "Fix: Add YouTube platform mapping and social media code fallback for CreativeX"
This reverts commit e327502723.
2026-02-13 17:16:41 +02:00
nickviljoen
e327502723 Fix: Add YouTube platform mapping and social media code fallback for CreativeX
YouTube Ads was missing from the DAM-CX mappings CSV, causing empty
Platform > Rating fields for YouTube assets. Also adds a fallback that
derives the CreativeX platform from the filename social media code (e.g.
YTA -> YouTube) when the database has no mapped platforms.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 17:00:35 +02:00
nickviljoen
a2f1954038 Fix: CreativeX tracking ID fallback, filename stripping, and social media codes
CreativeX lookup now falls back to tracking ID search when filename match fails
(handles mismatched naming from CreativeX PDFs). strip_upload_components now
only removes job number and tracking ID, keeping social media codes (YTA, DV3,
etc.) in the clean filename. Updated SOCIAL_MEDIA_CODES from 4 to 39 codes
sourced from the Ferrero naming tool.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 13:25:08 +02:00
nickviljoen
b89a44984d Fix: Pass notifier to process_box_file and use case-sensitive Master ID check
The notifier variable was referenced inside process_box_file but never passed
as a parameter, causing NameError for any file hitting the Master Tracking ID
check. Also changed the check from case-insensitive (.upper().startswith('M'))
to case-sensitive (.startswith('M')) to avoid false positives on random tracking
IDs like mviSv5.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 11:50:15 +02:00
nickviljoen
1b4e1a1cbc Fix: PPR MASTERASSETIDS payload updated to free text tabular field format
Changed from DomainValue structure to simple value structure per client specification.
Field is now a free text multivalue field instead of domain-based.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 15:28:37 +02:00
nickviljoen
26363f772d Enhancement: Campaign re-opening support and PPR master asset ID registration
A1→A2 now handles re-processing when campaign is reset to A1 after adding new
master assets. Existing assets reuse tracking IDs and skip Box upload, new assets
are processed normally. Also includes PPR domain registration for multiple master
asset IDs in a2_to_a3 and dam_client.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 21:06:14 +02:00
nickviljoen
444ac7ac6d Fix: PPR multiple master asset IDs now correctly populate MASTERASSETIDS field
Fixed issue where only 1 of 3 master asset IDs was being added to the
FERRERO.MASTERASSETIDS tabular field. The bug was caused by calling
_add_master_asset_id_field() before _add_master_asset_ids_field(),
which created the field with a single value and blocked the multi-value
method from adding all IDs.

Changes:
- metadata_extractor_mvp.py: Prioritize master_opentext_ids parameter
  using if/elif logic to prevent single-ID method from blocking multi-ID
- a2_to_a3_upload_polling.py: Load multiple master assets in PPR mode
- filename_parser.py: Parse multiple tracking IDs (e.g., ID1+ID2+ID3)
- query_db.py: Fix .env loading path
- Added documentation and test files for multiple master asset IDs

Tested in PPR with 3 tracking IDs (BqB8vo+SfUQ7m+laRJo0) - all 3 master
asset IDs now correctly appear in the metadata structure.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-03 21:02:09 +02:00
nickviljoen
04eccab9e7 Enhancement: Add environment-specific configurations and metadata improvements
This commit includes critical updates for PPR deployment:

1. Environment-Specific Field Mappings:
   - Created field_mappings_ppr.yaml with agency code "Oliver"
   - Created field_mappings_prod.yaml with agency code "0000221659"
   - Updated config_loader.py to auto-detect environment based on DAM URL
   - Enables seamless deployment between PPR and PROD environments

2. Metadata Extractor Enhancements:
   - Added MetadataTable extraction support for nested fields
   - Enables extraction of "Type of Video & Static Right" multi-value field
   - Added logic to apply defaults to existing but empty fields
   - Fixed agency name display_value handling for domain fields

3. Default Values Added:
   - VIDEO_POST_PROD_COMPANY: "Oliver Marketing Ltd"
   - AUDIO_POST_PROD_COMPANY: "Oliver Marketing Ltd"
   - PROD_COMPANY (Production House): "-"

These changes ensure:
- Correct agency codes per environment (PPR/PROD)
- Proper extraction of nested tabular fields
- Default values for empty production company fields
- Seamless deployment workflow

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-28 20:41:21 +02:00
nickviljoen
f83b4fae3e PPR Environment: Use SIMPLE metadata structure for tabular fields
Key Changes:
- Updated metadata_extractor_mvp.py to use SIMPLE structure for all tabular fields
- All tabular fields now use direct value objects (no MetadataTableFieldRow wrapper)
- MAIN_LANGUAGES, ASSETCOMPLIANCE, MARKETING_TAG, CREATIVEX all use SIMPLE structure
- Master Asset ID field updated to SIMPLE structure
- Date fields now use type 'string' instead of 'long'
- Matches DAM reference structure from asset_representation.json

Added Files:
- metadata_extractor_mvp_PROD.py: PROD-specific version with same SIMPLE structure
- Backup files for safety
- Analysis and comparison documentation

Environment:
- Tested and working in PPR environment (ppr.dam.ferrero.com)
- All tabular fields match DAM-supplied reference structure
- Successful uploads confirmed

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-23 16:52:50 +02:00
DJP
5a2273459c Fix: Restore MAIN_LANGUAGES and defaults to exact working structure from before Jan 19 changes 2026-01-20 08:37:41 -05:00
DJP
827a90ae71 Fix: Restore field_value wrapper to MAIN_LANGUAGES and defaults - revert to working structure 2026-01-20 08:06:52 -05:00
DJP
27c23bd98f Enhancement: Add timestamps to batch entries in daily report for better identification 2026-01-19 15:16:13 -05:00
DJP
a5b4c78b01 Fix: Increment campaigns_processed for file-based workflow batches to show in breakdown 2026-01-19 15:13:58 -05:00
DJP
72a02b3667 Fix: Add batch entries to workflow breakdown for file-based workflows in daily report 2026-01-19 15:12:48 -05:00
DJP
331f47d9ef Fix: Correct summary block parsing in daily report to capture all workflow activity 2026-01-19 15:09:40 -05:00
DJP
7eb99536b7 Fix: Add parsing for all workflow summary patterns in daily report 2026-01-19 15:05:27 -05:00
DJP
e77a385cce Fix: Remove field_value wrapper from MAIN_LANGUAGES to resolve null value error 2026-01-19 12:07:43 -05:00
DJP
a74d0914f9 Fix: Change date field type from 'date' to 'string' for MM/DD/YYYY format 2026-01-19 11:59:13 -05:00
DJP
4279bbc229 Fix: Correct JSON nesting for MAIN_LANGUAGES and Default Tabular Fields 2026-01-19 11:55:58 -05:00
DJP
c01b69e2fb Fix: Add MetadataTableFieldRow wrapper to all Tabular Fields (MAIN_LANGUAGES, CreativeX, Defaults) 2026-01-19 11:50:33 -05:00
DJP
4a1a4fffa0 Fix: Update Asset Validity date format to MM/DD/YYYY 2026-01-19 11:38:23 -05:00
DJP
fae3111467 Fix: Update Asset Validity date format to YYYY-MM-DD 2026-01-19 11:23:33 -05:00
DJP
e2c2719055 Fix: Add MetadataTableFieldRow wrapper to Tabular Master Asset ID field 2026-01-19 10:51:20 -05:00
DJP
4b5cb0a98a Fix: Correct inner column ID for Tabular Master Asset ID field 2026-01-19 10:45:47 -05:00
DJP
2ef92674d3 Feat: Add subfolder path to A2->A3 email notifications 2026-01-19 10:20:51 -05:00
DJP
ee6afe0888 Feat: Configurable Master Asset ID & Fix Date Type 2026-01-19 09:40:55 -05:00
DJP
0f984f3d7b Fix: Update asset validity date format to ISO-8601 string 2026-01-16 13:53:41 -05:00
DJP
631dba4390 Fix campaign ID storage - always set local_campaign_id
Critical Fix:
- extract_global_campaign_reference() now accepts campaign_id parameter
- Always sets local_campaign_id to current campaign as fallback
- Prevents NULL local_campaign_id when no Global Campaign Reference exists

Root Cause:
- Assets without Global Campaign Reference had NULL local_campaign_id
- Caused derivatives to be linked to wrong campaigns
- Same asset in multiple campaigns would share tracking IDs incorrectly

Impact:
- Every asset now has proper local_campaign_id
- Derivatives correctly linked to their source campaign
- Fixes issue where C000001177 assets were showing as C000002098

Changes:
- database.py: Added campaign_id parameter with fallback logic
- a1_to_a2_box_uploader.py: Pass campaign_number to function
- a5_to_a6_download.py: Pass campaign_number to function
2025-12-22 11:37:58 -05:00
DJP
5586dcc5de Simplify derivative storage - only store dam_asset_id
Reverted master_asset_id changes per user feedback:
- tracking_id already links derivatives to masters
- No need for additional master_asset_id foreign key
- Only storing dam_asset_id for DAM asset tracking

Changes:
- Reverted get_master_asset() to not return database 'id'
- Updated store_derivative_asset() to only INSERT dam_asset_id
- Updated a2_to_a3_upload_polling.py to pass None for master_asset_id
- Removed master_asset_id from INSERT statement

Note: Migration script still needed for dam_asset_id column only
2025-12-22 10:16:14 -05:00
DJP
c901a79e24 Fix A2→A3 email template and database logging issues
Email Template Fix:
- Fixed subject line syntax error in a2_to_a3_batch_complete template
- Removed Jinja2 control flow ({% if %}) from subject line
- Changed to simple expression-only format
- Fixes 'Failed to send email' error

Database Logging Fix:
- Updated get_master_asset() to return database primary key 'id'
- Updated store_derivative_asset() to actually store master_asset_id and dam_asset_id
- Updated a2_to_a3_upload_polling.py to pass master_asset['id'] instead of None
- Added migration script to add dam_asset_id column to derivative_assets table
- Fixes issue where derivatives weren't being linked to masters in database
- Enables proper lookups and tracking of uploaded derivatives

Impact:
- Email notifications will now send successfully
- Derivatives will be properly logged and linked to master assets
- Other tools can now find uploaded derivatives in database
2025-12-22 10:12:36 -05:00
DJP
222a53f466 Fix date field type error for ASSET VALIDITY START/END PERIOD
- Convert dates to milliseconds since epoch (Unix timestamp × 1000)
- Change field type from 'string' to 'long' for DATE fields
- Add _set_date_field_value() helper method for proper date handling
- Fixes 'java.lang.String was specified. Expecting java.util.Date' error
- Applies to A2->A3 uploads
2025-12-19 23:02:55 -05:00
DJP
5e8745580a Fix folder detection for folders with periods (v2)
- Enhanced logic to detect false-positive extensions like '. REFERENCE FILES'
- Checks if extension starts with period + space/uppercase (indicates folder name)
- Checks if extension contains spaces (not a valid file extension)
- Properly handles edge cases: '01. REFERENCE FILES', '02. OPEN FILES'
- Tested with multiple scenarios to ensure accuracy
2025-12-17 13:14:59 -05:00
DJP
6d7aa7e95a Fix folder detection for folders with periods in names
- Enhanced _get_assets_recursive() to properly identify folders vs files
- Added resource_type field validation (more reliable than asset_type)
- Created whitelist of 40+ known file extensions for accurate detection
- Fixes HTTP 404 errors when processing folders like '01. REFERENCE FILES'
- Applies to both A1->A2 and B1->B2 workflows
2025-12-17 13:06:02 -05:00
DJP
599d468e44 Add Master Asset ID field to A2→A3 uploads
- Added ARTESIA.FIELD.ASSET_ID to MVP fields in field_mappings.yaml
- Updated metadata_extractor_mvp.py to accept master_opentext_id parameter
- Added _add_master_asset_id_field() and _get_field_id() helper methods
- Modified a2_to_a3_upload_polling.py to pass master asset's opentext_id
- Field is populated with original master asset's DAM ID for derivative tracking
- Field is omitted for new assets (tracking ID with -N suffix)
- Covers both A2→A3 standard derivatives and A5→A6 reworked assets
2025-12-15 17:28:30 -05:00
DJP
022f232224 Fix UnboundLocalError in A1->A2 uploader and add error email 2025-12-10 08:36:16 -05:00
DJP
a7d17dd00d Add CSV attachment with campaign details to A1 and B1 success emails 2025-12-07 19:27:36 -05:00
DJP
9a3bf5d9cd Implement Master Tracking ID validation for A2-A3 uploads 2025-12-06 17:21:38 -05:00
DJP
160ef8ad43 Implement prefix-based tracking ID system for master files
- Master files (B1→B2) now always start with 'M' prefix
- Regular files (A1→A2, A5→A6) never start with 'M'
- Updated generate_unique_tracking_id() to accept is_master parameter
- All tracking IDs remain 6 characters in length
- No database schema changes required
2025-12-06 10:01:05 -05:00
DJP
4724fa3333 feat: Add A2-A3 batch upload completion notification template. 2025-12-03 17:05:39 -05:00
DJP
bce739d116 feat: Automatically set asset validity dates in the metadata extractor and update the agency name in field mappings. 2025-12-03 14:28:59 -05:00
DJP
85b39c49cb Add debug script for B1 pagination issue 2025-12-02 09:44:10 -05:00
DJP
ea2e313185 feat: Add systemd services and timers for daily and weekly database backups, introduce a token retrieval script, and update the backup guide documentation. 2025-12-01 22:19:24 -05:00
DJP
9b24ca1594 Add systemd service files for Prod Orchestrator and CreativeX Service 2025-12-01 16:09:26 -05:00
DJP
ca11c0dbb4 Fix NameError: Restore missing import in dam_client.py 2025-12-01 15:31:30 -05:00
DJP
69ffdeb14e Add CreativeX service runner and fix dam_client indentation 2025-12-01 15:29:27 -05:00
DJP
5f389f6490 Implement robust Box name sanitization in shared/common.py 2025-12-01 15:23:01 -05:00