Skip to main content

flet-media-scanner

A Flet extension for Android MediaStore integration — save, list, and delete videos in the device Gallery without requiring broad storage permissions.

Requirements

  • Platform: Android only (no-op on other platforms)
  • Android: API 23+ (minSdk 23)
  • Flet: >= 0.86.0

Installation

pip install flet-media-scanner

Setup

Register the extension in your pyproject.toml:

[tool.flet.extensions]
flet_media_scanner = "flet_media_scanner.Extension"

Usage

import flet as ft
from flet_media_scanner import MediaScanner, SaveResult

async def main(page: ft.Page):
    scanner = MediaScanner()
    page.services.append(scanner)
    page.update()

    # Save a video to the Gallery (Movies/MyApp folder)
    result: SaveResult = await scanner.save_video(
        "/data/user/0/com.example.app/cache/video.mp4",
        file_name="my_video.mp4",
        album="MyApp",
    )
    if result.success:
        print(f"Saved: {result.content_uri}")
    else:
        print(f"Error: {result.error}")

    # List videos in the album
    videos = await scanner.list_videos(album="MyApp")
    for v in videos:
        print(v["display_name"], v["content_uri"])

    # Delete a video by content URI
    deleted = await scanner.delete_video("content://media/external/video/media/123")
    print("Deleted:", deleted)

ft.run(main)

API

MediaScanner (Service)

Add to page.services before calling any methods.

await save_video(file_path, file_name=None, album="MyApp") → SaveResult

Copies a private app file into Android MediaStore (Movies/<album>). Works on Android 10+ without broad storage permissions.

Parameter Type Description
file_path str Absolute path to the source video file
file_name str | None Display name in Gallery (defaults to basename)
album str Subfolder inside Movies/

await list_videos(album="MyApp") → list[dict]

Returns all videos previously saved to the album. Each dict contains: display_name, content_uri, mime_type, relative_path, size, date_added.

await delete_video(content_uri) → bool

Deletes a MediaStore item by its content:// URI.

await scan_media(file_path) → bool

(Legacy) Triggers a media scan for a file that already exists in public storage. Use save_video() for new downloads instead.


SaveResult (dataclass)

Field Type Description
success bool Whether the operation succeeded
content_uri str MediaStore content:// URI
display_name str File name as shown in Gallery
mime_type str e.g. video/mp4
relative_path str e.g. Movies/MyApp/
size int File size in bytes
error str Error message if success=False

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flet_media_scanner-0.86.1.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flet_media_scanner-0.86.1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file flet_media_scanner-0.86.1.tar.gz.

File metadata

  • Download URL: flet_media_scanner-0.86.1.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for flet_media_scanner-0.86.1.tar.gz
Algorithm Hash digest
SHA256 839726fb873ec3e341b125eeeb1855f5b1b84009890bc6c4fde4e2e5d65a7448
MD5 0e6aebe0ea1b1e01188bcd3d46680974
BLAKE2b-256 e78fe96b769434f7227f90d0d7cc2312980824db94a3943cfa88843538c6de6e

See more details on using hashes here.

File details

Details for the file flet_media_scanner-0.86.1-py3-none-any.whl.

File metadata

File hashes

Hashes for flet_media_scanner-0.86.1-py3-none-any.whl
Algorithm Hash digest
SHA256 75c52e5c3114f655177c2d1ea8e5a75b661471a2f87daea6abe078cc87815479
MD5 885def4535156bce4b224653ea465a37
BLAKE2b-256 b59fcce8662cc4e08b9e028037923e912dbfe968cf919079d9a05c84132c23e4

See more details on using hashes here.

Release history Release notifications | RSS feed

1.7.0

2 files

1.6.0

2 files

1.5.0

2 files

1.4.0

2 files

1.3.0

2 files

1.2.0

2 files

1.1.0

2 files

1.0.1

2 files

1.0.0

2 files

0.86.5

2 files

0.86.4

2 files

0.86.3

2 files

0.86.2

2 files

This release

0.86.1 This release

2 files

0.86.0

2 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