forked from Sankar8098/Advanced-File-Store-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmovie_processor.py
More file actions
73 lines (62 loc) · 2.35 KB
/
Copy pathmovie_processor.py
File metadata and controls
73 lines (62 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import os
import asyncio
import aiohttp
from typing import Optional, Dict
from datetime import datetime
from database import get_db, create_movie
import hashlib
import json
class MovieProcessor:
def __init__(self):
self.supported_platforms = {
'gdrive': self._process_gdrive,
'mega': self._process_mega,
'direct': self._process_direct
}
async def process_movie(self,
title: str,
file_url: str,
platform: str,
description: Optional[str] = None,
year: Optional[int] = None,
genre: Optional[str] = None) -> Dict:
"""Process movie and generate streaming links."""
if platform not in self.supported_platforms:
raise ValueError(f"Unsupported platform: {platform}")
# Generate unique stream ID
stream_id = self._generate_stream_id(title, file_url)
# Process the URL based on platform
processed_url = await self.supported_platforms[platform](file_url)
# Store in database
with get_db() as db:
movie = create_movie(
db=db,
title=title,
stream_id=stream_id,
file_url=processed_url,
description=description,
year=year,
genre=genre,
uploader_id=0 # System upload
)
return {
'stream_id': stream_id,
'processed_url': processed_url,
'title': title,
'year': year
}
def _generate_stream_id(self, title: str, url: str) -> str:
"""Generate unique stream ID."""
unique_string = f"{title}{url}{datetime.now().isoformat()}"
return hashlib.sha256(unique_string.encode()).hexdigest()[:16]
async def _process_gdrive(self, url: str) -> str:
"""Process Google Drive links."""
# Add your Google Drive processing logic here
return url
async def _process_mega(self, url: str) -> str:
"""Process Mega links."""
# Add your Mega processing logic here
return url
async def _process_direct(self, url: str) -> str:
"""Process direct links."""
return url