Skip to main content

SimpleSyntax

SimpleSyntax is a lightweight, CSS-selector-inspired Python library for downloading media and extracting metadata from various platforms. It provides a clean, declarative API for handling complex downloading tasks, including automatic fallback mechanisms, cookie management, and metadata extraction.

Requirements

  • Python >= 3.9
  • yt-dlp
  • gallery-dl
  • ffmpeg (required for merging audio/video streams)

Installation

SimpleSyntax is designed to be used as a drop-in library. Ensure you have the required dependencies installed:

pip install yt-dlp gallery-dl

Basic Usage

The library provides a single entry point, rz, which allows you to define the operations you want to perform using a selector-based syntax.

from SimpleSyntax import rz

url = "https://example.com/video"

# Perform operations and bind results to variables in your current scope
rz({
    "video[3]": "my_video",
    "title": "video_title"
}, url)

print(f"Downloaded: {my_video}")
print(f"Title: {video_title}")

Selector Syntax

SimpleSyntax uses a CSS-inspired selector syntax to define tasks.

Media Selectors

Media selectors support a quality index from 0 to 6:

  • video[N]: Downloads video content.
  • media[N]: Attempts to download as video; falls back to image downloading if the video engine fails.

Quality Index (N):

  • 0: Audio only
  • 1: 360p
  • 2: 480p
  • 3: 720p
  • 4: 1080p
  • 5: 1440p
  • 6: Best quality

Metadata Selectors

Extract information without downloading the media:

  • title
  • creator
  • url
  • views (formatted)
  • likes (formatted)
  • comments (formatted)
  • duration (formatted)
  • thumbnail
  • date (YYYY/MM/DD)
  • live (True/False)

SimpleSyntax includes a resilient fallback system:

  1. No-Cookie Attempt: Every operation is first attempted without cookies.
  2. Ranked Cookie Fallback: If the first attempt fails, SimpleSyntax ranks user-supplied cookie files by calculating the similarity between the target URL and the cookie filename (using host/path matching).
  3. Automatic Retry: It sequentially retries the operation using the ranked cookies, stopping at the first successful attempt.
  4. History: Successful cookie-URL associations are cached to improve future ranking.

To enable cookie support, define a ReiZyuki list/tuple in your caller's scope containing paths to your cookie files:

ReiZyuki = ["/path/to/cookies.txt"]

Playlist Handling

SimpleSyntax supports downloading segments of playlists. Note: Usage requires providing a string value in the format QUALITY:SKIP:COUNT.

  • rz({"playlist": "3:0:5"}, url) - Download 5 videos starting from index 0, in 720p quality.

Author: ReiZyuki

Metadata

Release files for simplesyntax 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for simplesyntax 0.1.2
File Interpreter ABI Platform
simplesyntax-0.1.2-py3-none-any.whl Python 3 none any Details

Release files / simplesyntax-0.1.2-py3-none-any.whl

Download URL simplesyntax-0.1.2-py3-none-any.whl
Size 13.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e57bfb6b3fd103387a0b5e470770350b59941a8212c9dcff41b54fbed7e391ff
BLAKE2b-256 checksum
How to use checksums
63742943ef0bdae178644c2da30021e6036144cfbc1c9583838dd18c380ee0df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release history Release notifications | RSS feed

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

This release

0.1.2 This release

1 release file

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page