Team Ai
Apppublic

alphanet06/processor

sourceHugging Faceupdated 11mo agoView on Hugging Face
0likes
App README

N_m3u8DL-RE DRM Processor with Google Drive Integration

This service processes DRM-protected streams and automatically:

  1. 1.Downloads and decrypts the content
  2. 2.Converts to MP4 format
  3. 3.Uploads to Google Drive
  4. 4.Returns a shareable Google Drive link

Features

  • —N_m3u8DL-RE v0.3.0-beta: DASH/HLS/MSS downloader with DRM support
  • —Automatic MP4 Conversion: MKV to MP4 with FFmpeg
  • —Google Drive Integration: Automatic upload of processed files with shareable links
  • —FastAPI Server: RESTful API for job management and file access

API Endpoints

Process a Stream

bash
curl -X POST "http://localhost:7860/process" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/stream.mpd",
    "save_name": "my_video",
    "key": "your_decryption_key",
    "binary_merge": true
  }'

Check Job Status

bash
curl "http://localhost:7860/jobs/{job_id}"

The response will include:

  • —filename: The processed MP4 filename
  • —url: Local stream URL
  • —gdrive_link: Google Drive shareable link

List All Jobs

bash
curl "http://localhost:7860/jobs"

Health Check

bash
curl "http://localhost:7860/health"

Check Google Drive Credentials

bash
curl "http://localhost:7860/check_gdrive"

This endpoint will provide detailed diagnostics about:

  • —Whether credentials.json is found and accessible
  • —File sizes and locations
  • —Authentication status
  • —Current working directory
  • —Files in the directory

Debug System Information

bash
curl "http://localhost:7860/debug"

Shows comprehensive system information including:

  • —All files visible to the application
  • —Git status (if available)
  • —Environment variables
  • —File permissions and details

Use this to troubleshoot deployment issues on HuggingFace.

Setup

Prerequisites

  • —Docker (for containerized deployment)
  • —Google Drive API credentials (client_secrets.json)

CRITICAL: Required Files for Deployment

You MUST upload ALL of these files to HuggingFace:

  1. 1.Authentication Files (REQUIRED for Google Drive):
  2. 2.credentials.json (1.5 KB) - Generated by authenticating locally
  3. 3.settings.yaml (0.4 KB) - PyDrive2 configuration
  4. 4.client_secrets.json (0.4 KB) - OAuth credentials
  1. 1.Application Files:
  2. 2.app.py (28.5 KB) - Main application with Google Drive integration
  3. 3.requirements.txt (0.1 KB) - Python dependencies
  4. 4.Dockerfile - Container configuration

⚠️ IMPORTANT: All files must be in the root directory of your HuggingFace space, same level as app.py

Note: The Dockerfile has been updated to automatically copy the authentication files into the container, but you still need to commit them to git first.

Google Drive Setup

IMPORTANT: For server deployment (HuggingFace, Docker, etc.), you must generate credentials locally first.

Step 1: Generate Credentials Locally

Run this script on your local machine (not on the server):

bash
python generate_credentials.py

This will:

  1. 1.Open your browser for Google authentication
  2. 2.Ask you to grant access to Google Drive
  3. 3.Generate a credentials.json file
Step 2: Deploy to Server

Upload these files to your server/HuggingFace space:

  • —credentials.json (just generated)
  • —settings.yaml (already configured)
  • —client_secrets.json (already configured)

These files must be in the same directory as app.py.

Step 3: Verify

After deployment, the app will automatically:

  • —Use the pre-generated credentials
  • —Refresh the access token when expired
  • —Save updated credentials back to the file

Response Format

When a job completes successfully, you'll receive:

json
{
  "job_id": "uuid",
  "status": "completed",
  "filename": "my_video.mp4",
  "url": "/stream/my_video.mp4",
  "file_size_mb": 150.5,
  "converted_to_mp4": true,
  "gdrive_link": "https://drive.google.com/file/d/..."
}

Local Testing

The integration has been tested locally and verified:

  • —✅ Google Drive upload working
  • —✅ MP4 conversion working
  • —✅ File processing and serving working

Troubleshooting

Google Drive Issues

If you see "credentials.json not found" errors:

  1. 1.Check credentials are uploaded: Visit https://your-space.hf.space/check_gdrive to see detailed diagnostics
  1. 1.Verify file locations: All these files must be in the same directory as app.py:
  2. 2.credentials.json (1,551 bytes)
  3. 3.settings.yaml (424 bytes)
  4. 4.client_secrets.json (411 bytes)
  1. 1.Regenerate credentials if needed:
bash
   python authenticate_gdrive.py  # Run locally
   # Upload the generated credentials.json to HuggingFace
  1. 1.Check file permissions: Ensure the credentials.json file isn't corrupted during upload

Common Issues

  • —Empty credentials.json: File exists but size is 0 bytes
  • —Wrong directory: Files are in a subdirectory instead of the root
  • —Corrupted upload: File was corrupted during HuggingFace upload
  • —Missing settings.yaml: Required for PyDrive2 authentication

Notes

  • —Files are automatically converted to MP4 after processing
  • —Google Drive upload only occurs for MP4 files
  • —All operations are asynchronous and tracked via job IDs
  • —Use /debug endpoint for detailed troubleshooting