alphanet06/processor
N_m3u8DL-RE DRM Processor with Google Drive Integration
This service processes DRM-protected streams and automatically:
- Downloads and decrypts the content
- Converts to MP4 format
- Uploads to Google Drive
- 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
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
curl "http://localhost:7860/jobs/{job_id}"The response will include:
filename: The processed MP4 filenameurl: Local stream URLgdrive_link: Google Drive shareable link
List All Jobs
curl "http://localhost:7860/jobs"Health Check
curl "http://localhost:7860/health"Check Google Drive Credentials
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
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:
- Authentication Files (REQUIRED for Google Drive):
credentials.json(1.5 KB) - Generated by authenticating locallysettings.yaml(0.4 KB) - PyDrive2 configurationclient_secrets.json(0.4 KB) - OAuth credentials
- Application Files:
app.py(28.5 KB) - Main application with Google Drive integrationrequirements.txt(0.1 KB) - Python dependenciesDockerfile- 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):
python generate_credentials.pyThis will:
- Open your browser for Google authentication
- Ask you to grant access to Google Drive
- Generate a
credentials.jsonfile
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:
{
"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:
- Check credentials are uploaded: Visit
https://your-space.hf.space/check_gdriveto see detailed diagnostics
- Verify file locations: All these files must be in the same directory as
app.py: credentials.json(1,551 bytes)settings.yaml(424 bytes)client_secrets.json(411 bytes)
- Regenerate credentials if needed:
python authenticate_gdrive.py # Run locally
# Upload the generated credentials.json to HuggingFace- 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
/debugendpoint for detailed troubleshooting
