alphanet06/processor
0
1---2title: Processor3emoji: ๐4colorFrom: indigo5colorTo: yellow6sdk: docker7pinned: false8---9 10# N_m3u8DL-RE DRM Processor with Google Drive Integration11 12This service processes DRM-protected streams and automatically:131. Downloads and decrypts the content142. Converts to MP4 format153. Uploads to Google Drive164. Returns a shareable Google Drive link17 18## Features19 20- **N_m3u8DL-RE v0.3.0-beta**: DASH/HLS/MSS downloader with DRM support21- **Automatic MP4 Conversion**: MKV to MP4 with FFmpeg22- **Google Drive Integration**: Automatic upload of processed files with shareable links23- **FastAPI Server**: RESTful API for job management and file access24 25## API Endpoints26 27### Process a Stream28```bash29curl -X POST "http://localhost:7860/process" \30 -H "Content-Type: application/json" \31 -d '{32 "url": "https://example.com/stream.mpd",33 "save_name": "my_video",34 "key": "your_decryption_key",35 "binary_merge": true36 }'37```38 39### Check Job Status40```bash41curl "http://localhost:7860/jobs/{job_id}"42```43 44The response will include:45- `filename`: The processed MP4 filename46- `url`: Local stream URL47- `gdrive_link`: Google Drive shareable link48 49### List All Jobs50```bash51curl "http://localhost:7860/jobs"52```53 54### Health Check55```bash56curl "http://localhost:7860/health"57```58 59### Check Google Drive Credentials60```bash61curl "http://localhost:7860/check_gdrive"62```63 64This endpoint will provide detailed diagnostics about:65- Whether credentials.json is found and accessible66- File sizes and locations67- Authentication status68- Current working directory69- Files in the directory70 71### Debug System Information72```bash73curl "http://localhost:7860/debug"74```75 76Shows comprehensive system information including:77- All files visible to the application78- Git status (if available)79- Environment variables80- File permissions and details81 82Use this to troubleshoot deployment issues on HuggingFace.83 84## Setup85 86### Prerequisites87 88- Docker (for containerized deployment)89- Google Drive API credentials (client_secrets.json)90 91### CRITICAL: Required Files for Deployment92 93**You MUST upload ALL of these files to HuggingFace:**94 951. **Authentication Files (REQUIRED for Google Drive):**96 - `credentials.json` (1.5 KB) - Generated by authenticating locally97 - `settings.yaml` (0.4 KB) - PyDrive2 configuration98 - `client_secrets.json` (0.4 KB) - OAuth credentials99 1002. **Application Files:**101 - `app.py` (28.5 KB) - Main application with Google Drive integration102 - `requirements.txt` (0.1 KB) - Python dependencies103 - `Dockerfile` - Container configuration104 105**โ ๏ธ IMPORTANT:** All files must be in the **root directory** of your HuggingFace space, same level as app.py106 107**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.108 109### Google Drive Setup110 111**IMPORTANT**: For server deployment (HuggingFace, Docker, etc.), you must generate credentials locally first.112 113#### Step 1: Generate Credentials Locally114 115Run this script on your local machine (not on the server):116 117```bash118python generate_credentials.py119```120 121This will:1221. Open your browser for Google authentication1232. Ask you to grant access to Google Drive1243. Generate a `credentials.json` file125 126#### Step 2: Deploy to Server127 128Upload these files to your server/HuggingFace space:129- `credentials.json` (just generated)130- `settings.yaml` (already configured)131- `client_secrets.json` (already configured)132 133These files must be in the same directory as `app.py`.134 135#### Step 3: Verify136 137After deployment, the app will automatically:138- Use the pre-generated credentials139- Refresh the access token when expired140- Save updated credentials back to the file141 142## Response Format143 144When a job completes successfully, you'll receive:145 146```json147{148 "job_id": "uuid",149 "status": "completed",150 "filename": "my_video.mp4",151 "url": "/stream/my_video.mp4",152 "file_size_mb": 150.5,153 "converted_to_mp4": true,154 "gdrive_link": "https://drive.google.com/file/d/..."155}156```157 158## Local Testing159 160The integration has been tested locally and verified:161- โ
Google Drive upload working162- โ
MP4 conversion working163- โ
File processing and serving working164 165## Troubleshooting166 167### Google Drive Issues168 169If you see "credentials.json not found" errors:170 1711. **Check credentials are uploaded**: Visit `https://your-space.hf.space/check_gdrive` to see detailed diagnostics172 1732. **Verify file locations**: All these files must be in the same directory as `app.py`:174 - `credentials.json` (1,551 bytes)175 - `settings.yaml` (424 bytes)176 - `client_secrets.json` (411 bytes)177 1783. **Regenerate credentials if needed**:179 ```bash180 python authenticate_gdrive.py # Run locally181 # Upload the generated credentials.json to HuggingFace182 ```183 1844. **Check file permissions**: Ensure the credentials.json file isn't corrupted during upload185 186### Common Issues187 188- **Empty credentials.json**: File exists but size is 0 bytes189- **Wrong directory**: Files are in a subdirectory instead of the root190- **Corrupted upload**: File was corrupted during HuggingFace upload191- **Missing settings.yaml**: Required for PyDrive2 authentication192 193## Notes194 195- Files are automatically converted to MP4 after processing196- Google Drive upload only occurs for MP4 files197- All operations are asynchronous and tracked via job IDs198- Use `/debug` endpoint for detailed troubleshooting