Metadata-Version: 2.5
Name: trytond_mediaserver_scraping
Version: 8.0.0.3
Summary: Media Server Scraping
Author: Clemens Hupka
Maintainer-email: Clemens Hupka <clemens.hupka@backend.at>
License-Expression: GPL-3.0-or-later
License-File: COPYRIGHT
License-File: LICENSE
Keywords: media,metadata,scraping,server,tryton
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Environment :: Plugins
Classifier: Framework :: Tryton
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Multimedia :: Video
Requires-Python: >=3.10
Requires-Dist: trytond-mediaserver<8.1,>=8.0
Requires-Dist: trytond<8.1,>=8.0
Provides-Extra: html
Requires-Dist: beautifulsoup4<8.1,>=8.0; extra == 'html'
Provides-Extra: http
Requires-Dist: requests<8.1,>=8.0; extra == 'http'
Provides-Extra: test
Description-Content-Type: text/x-rst

Mediaserver Scraping
====================

The ``mediaserver_scraping`` module provides metadata scraping from online
video sources (YouTube, Arte, ARD, France.tv) for the Tryton mediaserver.
It uses the ``yt-dlp`` library as its backend and stores extracted
metadata (title, description, duration, codecs, resolution, etc.) in
scraping results that can be applied to existing or new media files.

Features
--------

- **Scraper configuration**: Define scrapers per source type with a
  selectable backend (currently ``yt-dlp``) and optional API credentials
  or extra options passed as a JSON dict.
- **Scraping jobs**: Queue-based scraping tasks with workflow states
  (draft → queued → running → done / failed / cancelled) and full
  error capture.
- **Metadata extraction**: Title, description, duration, uploader,
  upload date, year, thumbnail URL, language, resolution, video and
  audio codecs, frame rate, aspect ratio, bitrate, file and container
  format, tags, raw metadata, extractor, and webpage URL.
- **Apply results to media files**: Scraping results can be applied to
  an existing ``MediaFile`` (matched by source type + source id) or
  used to create a new one, with automatic keyword creation from tags.
- **Interactive wizard**: A wizard allows one-off scraping by entering
  a URL, selecting a scraper, fetching metadata, previewing the result,
  and applying it directly to a media file.

Configuration
-------------

The module uses the ``[mediaserver]`` configuration section of
``trytond.conf``. It does not define any module-specific configuration
keys.

Scraper records are pre-configured via XML data for the following
sources:

- YouTube (yt-dlp)
- Arte (yt-dlp)
- ARD (yt-dlp)
- France.tv (yt-dlp)

Each scraper references a ``mediaserver.source_type`` and the
``yt-dlp`` backend. Optional ``extra_options`` can be set on each
scraper as a JSON dict (e.g. ``{"geo_bypass": "DE"}``) and are merged
into the yt-dlp options at scraping time.

Dependencies
------------

- Python package ``yt-dlp`` (install with ``pip install yt-dlp``).
- Tryton module ``mediaserver``.

Models
------

- ``mediaserver_scraping.scraper`` — Scraper: a configured source and
  backend used to extract metadata.
- ``mediaserver_scraping.job`` — ScrapingJob: a workflow-based
  scraping task that runs against a single URL.
- ``mediaserver_scraping.result`` — ScrapingResult: the extracted
  metadata for a job, applied to a ``MediaFile``.

Cron Jobs
---------

- ``cron_scraping_queue``: Runs every 5 minutes and calls
  ``mediaserver_scraping.job|process_queue`` to process queued scraping
  jobs.

Wizards
-------

- ``ScrapingWizard``: URL and scraper selection → fetch metadata →
  preview → apply to a ``MediaFile``.
