The ObjServiceYoutube is an Axion service designed to download the audio track from a given YouTube video URL, enrich it with metadata, and register it as a managed document within the Axion framework.
It utilizes the yt-dlp library for reliable video information extraction and audio downloading, and the ObjDocument class for seamless integration with the Axion document management system.
data_documentfile table.Name)Description)MediaDuration)Author)Tags)ReferenceGuid) and skips the process if it has.local.documents/youtube/.ObjServiceApi_IsA (str): Identifier for the service. Set to "YoutubeDownloader".ServiceCode (str): The code used to look up service definitions. Set to "YOUTUBE".Param1 (str): Required. The full URL of the YouTube video.Param2 (str): Required. The desired filename for the output MP3 (e.g., my-audio.mp3). The service handles the full path.Result1 (str): A high-level status of the execution (SUCCESS, ERROR, SKIPPED).Result2 (str): A detailed message describing the outcome.Connect():
data_documentfile.False if validation fails, a duplicate is found, or metadata extraction fails.Send():
build_detail() to commit all metadata to the database.run_workflow_direct(param1, param2, param3): The primary entry point for the Axion workflow engine.python /path/to/ObjServiceYoutube.py [URL] [FILENAME]
URL: (Required) The full YouTube video URL.FILENAME: (Required) The desired output filename for the MP3 (e.g., my-audio.mp3).python factory/service/package/core/ObjServiceYoutube.py "https://www.youtube.com/watch?v=dQw4w9WgXcQ" "rick_astley.mp3"
Service execution finished.
Status: SUCCESS
Result: Audio 'Rick Astley - Never Gonna Give You Up (Official Music Video)' downloaded and registered. (GUID: <generated_guid>)
Service execution finished.
Status: SKIPPED
Result: Duplicate video. Already exists with GUID: <existing_guid>
from factory.service.package.core.ObjServiceYoutube import ObjServiceApi
# Instantiate the service
youtube_downloader = ObjServiceApi()
# Define parameters
video_url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
output_filename = "rick_astley.mp3"
# Execute the service
result_message = youtube_downloader.run_workflow_direct(param1=video_url, param2=output_filename)
# Check the results
print(f"Status: {youtube_downloader.Result1}")
print(f"Message: {result_message}")