Rubka 7.2.8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. rubka/__init__.py +79 -0
  2. rubka/adaptorrubka/__init__.py +4 -0
  3. rubka/adaptorrubka/client/__init__.py +1 -0
  4. rubka/adaptorrubka/client/client.py +60 -0
  5. rubka/adaptorrubka/crypto/__init__.py +1 -0
  6. rubka/adaptorrubka/crypto/crypto.py +82 -0
  7. rubka/adaptorrubka/enums.py +36 -0
  8. rubka/adaptorrubka/exceptions.py +22 -0
  9. rubka/adaptorrubka/methods/__init__.py +1 -0
  10. rubka/adaptorrubka/methods/methods.py +90 -0
  11. rubka/adaptorrubka/network/__init__.py +3 -0
  12. rubka/adaptorrubka/network/helper.py +22 -0
  13. rubka/adaptorrubka/network/network.py +221 -0
  14. rubka/adaptorrubka/network/socket.py +31 -0
  15. rubka/adaptorrubka/sessions/__init__.py +1 -0
  16. rubka/adaptorrubka/sessions/sessions.py +72 -0
  17. rubka/adaptorrubka/types/__init__.py +1 -0
  18. rubka/adaptorrubka/types/socket/__init__.py +1 -0
  19. rubka/adaptorrubka/types/socket/message.py +187 -0
  20. rubka/adaptorrubka/utils/__init__.py +2 -0
  21. rubka/adaptorrubka/utils/configs.py +18 -0
  22. rubka/adaptorrubka/utils/utils.py +251 -0
  23. rubka/api.py +1723 -0
  24. rubka/asynco.py +2541 -0
  25. rubka/button.py +404 -0
  26. rubka/config.py +3 -0
  27. rubka/context.py +1077 -0
  28. rubka/decorators.py +30 -0
  29. rubka/exceptions.py +37 -0
  30. rubka/filters.py +330 -0
  31. rubka/helpers.py +1461 -0
  32. rubka/jobs.py +15 -0
  33. rubka/keyboards.py +16 -0
  34. rubka/keypad.py +298 -0
  35. rubka/logger.py +12 -0
  36. rubka/metadata.py +114 -0
  37. rubka/rubino.py +1271 -0
  38. rubka/tv.py +145 -0
  39. rubka/update.py +1038 -0
  40. rubka/utils.py +3 -0
  41. rubka-7.2.8.dist-info/METADATA +1047 -0
  42. rubka-7.2.8.dist-info/RECORD +45 -0
  43. rubka-7.2.8.dist-info/WHEEL +5 -0
  44. rubka-7.2.8.dist-info/entry_points.txt +2 -0
  45. rubka-7.2.8.dist-info/top_level.txt +1 -0
rubka/tv.py ADDED
@@ -0,0 +1,145 @@
1
+ import asyncio
2
+ import random
3
+ from typing import Optional, Dict, Any
4
+
5
+ import httpx
6
+
7
+ class TV:
8
+ BASE_URL_TEMPLATE = "https://rbvod{}.iranlms.ir/"
9
+ META_URL = "https://tv.rubika.ir/meta.json"
10
+
11
+ DEFAULT_HEADERS = {
12
+ 'accept': '*/*',
13
+ 'accept-encoding': 'gzip, deflate, br, zstd',
14
+ 'accept-language': 'fa',
15
+ 'content-type': 'application/json;charset=UTF-8',
16
+ 'origin': 'https://tv.rubika.ir',
17
+ 'referer': 'https://tv.rubika.ir/',
18
+ 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36'
19
+ }
20
+
21
+ def __init__(
22
+ self,
23
+ auth: str,
24
+ proxy: Optional[str] = None,
25
+ headers: Optional[Dict[str, str]] = None
26
+ ) -> None:
27
+ """
28
+ - auth: توکن احراز هویت حساب کاربری
29
+ - proxy: پراکسی برای ارسال درخواست‌ها (اختیاری)
30
+ - headers: هدرهای سفارشی برای ارسال درخواست‌ها (اختیاری)
31
+ # نکته:
32
+ https://vod.rubika.ir/
33
+ """
34
+ self.auth = auth
35
+ self.headers = headers if headers is not None else self.DEFAULT_HEADERS
36
+ self._version: Optional[str] = None
37
+ self.client = httpx.AsyncClient(
38
+ headers=self.headers,
39
+ proxies=proxy,
40
+ timeout=15.0,
41
+ http2=True
42
+ )
43
+
44
+ async def _get_version(self) -> str:
45
+ if self._version is None:
46
+ try:
47
+ response = await self.client.get(self.META_URL)
48
+ response.raise_for_status()
49
+ self._version = response.json()['version']
50
+ except httpx.RequestError:
51
+ self._version = "3.2.3"
52
+ return self._version
53
+
54
+ def _get_request_url(self) -> str:
55
+ return self.BASE_URL_TEMPLATE.format(random.randint(1, 4))
56
+
57
+ async def _request_post(self, method: str, data: Dict[str, Any]) -> Dict[str, Any]:
58
+ payload = {
59
+ "auth": self.auth,
60
+ "api_version": "1",
61
+ "client": {
62
+ "app_name": "Main",
63
+ "app_version": await self._get_version(),
64
+ "package": "tv.rubika.ir",
65
+ "platform": "TVWeb",
66
+ "lang_code": "fa"
67
+ },
68
+ "data": data,
69
+ "method": method
70
+ }
71
+
72
+ try:
73
+ response = await self.client.post(self._get_request_url(), json=payload)
74
+ response.raise_for_status()
75
+ response_data = response.json()
76
+
77
+ if 'data' in response_data:
78
+ return response_data['data']
79
+ elif 'status_det' in response_data:
80
+ return {'status_detail': response_data['status_det']}
81
+ raise ValueError("پاسخ نامعتبر از سرور دریافت شد.")
82
+
83
+ except httpx.RequestError as e:
84
+
85
+ raise ConnectionError(f"خطا در ارتباط با سرور: {e}") from e
86
+
87
+
88
+
89
+
90
+ async def get_list_items(self, list_id: str, type: str = "Media", start_id: str = "0"):
91
+ return await self._request_post("getListItems", {"list_id": list_id, "type": type, "start_id": start_id})
92
+
93
+ async def get_media_by_id(self, media_id: str,track_id:str=None):
94
+ return await self._request_post("getMedia", {"media_id": media_id,"track_id":track_id})
95
+
96
+ async def get_custom_menu_items(self):
97
+ return await self._request_post("getCustomMenuItems", {})
98
+
99
+ async def get_wish_list(self, start_id: Optional[str] = None):
100
+ return await self._request_post("getWishList", {"start_id": start_id})
101
+
102
+ async def get_Property_Types(self):
103
+ return await self._request_post("getPropertyTypes", {})
104
+
105
+ async def get_Listing(self, listing_id: Optional[str] = "home"):
106
+ return await self._request_post("getListing", {"listing_id": listing_id})
107
+
108
+ async def get_me(self):
109
+ return await self._request_post("getAccountInfo", {})
110
+
111
+ async def search_video(self, text: str, start_id: Optional[str] = None):
112
+ return await self._request_post("search", {'search_text': text, 'start_id': start_id})
113
+
114
+ async def _action_on_media(self, action: str, media_id: str):
115
+
116
+ return await self._request_post('actionOnMedia', {'action': action, 'media_id': media_id})
117
+
118
+ async def like_media(self, media_id: str):
119
+ return await self._action_on_media("Like", media_id)
120
+
121
+ async def un_like_media(self, media_id: str):
122
+ return await self._action_on_media("Dislike", media_id)
123
+
124
+ async def add_wish_media(self, media_id: str):
125
+ return await self._action_on_media("AddWishList", media_id)
126
+
127
+ async def get_cast_medias(self, cast_id: str, start_id: str = "0"):
128
+ return await self._request_post("getCastMedias", {'cast_id': cast_id, 'start_id': start_id})
129
+
130
+ async def get_cast_info(self, cast_id: str):
131
+ return await self._request_post("getCastDetails", {'cast_id': cast_id})
132
+ async def get_Season_Episodes(self, season_id: str,series_id:str):
133
+ return await self._request_post("getSeasonEpisodes", {'season_id': season_id,"series_id":series_id})
134
+ async def get_Related(self, media_id: str,start_id:str="0"):
135
+ return await self._request_post("getRelated", {'media_id': media_id,"start_id":start_id})
136
+
137
+
138
+ async def close(self):
139
+ await self.client.aclose()
140
+
141
+ async def __aenter__(self):
142
+ return self
143
+
144
+ async def __aexit__(self, exc_type, exc_val, exc_tb):
145
+ await self.close()