Rubka 6.6.8__py3-none-any.whl → 6.6.10__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.

Potentially problematic release.


This version of Rubka might be problematic. Click here for more details.

rubka/__init__.py CHANGED
@@ -70,6 +70,7 @@ from .api import Robot
70
70
  from .rubino import Bot
71
71
  from .exceptions import APIRequestError
72
72
  from .rubino import Bot as rubino
73
+ from .tv import TV as Client
73
74
 
74
75
  __all__ = [
75
76
  "Robot",
rubka/tv.py ADDED
@@ -0,0 +1,137 @@
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
+ self.auth = auth
33
+ self.headers = headers if headers is not None else self.DEFAULT_HEADERS
34
+ self._version: Optional[str] = None
35
+ self.client = httpx.AsyncClient(
36
+ headers=self.headers,
37
+ proxies=proxy,
38
+ timeout=15.0,
39
+ http2=True
40
+ )
41
+
42
+ async def _get_version(self) -> str:
43
+ if self._version is None:
44
+ try:
45
+ response = await self.client.get(self.META_URL)
46
+ response.raise_for_status()
47
+ self._version = response.json()['version']
48
+ except httpx.RequestError:
49
+ self._version = "3.2.3"
50
+ return self._version
51
+
52
+ def _get_request_url(self) -> str:
53
+ return self.BASE_URL_TEMPLATE.format(random.randint(1, 4))
54
+
55
+ async def _request_post(self, method: str, data: Dict[str, Any]) -> Dict[str, Any]:
56
+ payload = {
57
+ "auth": self.auth,
58
+ "api_version": "1",
59
+ "client": {
60
+ "app_name": "Main",
61
+ "app_version": await self._get_version(),
62
+ "package": "tv.rubika.ir",
63
+ "platform": "TVWeb",
64
+ "lang_code": "fa"
65
+ },
66
+ "data": data,
67
+ "method": method
68
+ }
69
+
70
+ try:
71
+ response = await self.client.post(self._get_request_url(), json=payload)
72
+ response.raise_for_status()
73
+ response_data = response.json()
74
+
75
+ if 'data' in response_data:
76
+ return response_data['data']
77
+ elif 'status_det' in response_data:
78
+ return {'status_detail': response_data['status_det']}
79
+ raise ValueError("پاسخ نامعتبر از سرور دریافت شد.")
80
+
81
+ except httpx.RequestError as e:
82
+
83
+ raise ConnectionError(f"خطا در ارتباط با سرور: {e}") from e
84
+
85
+
86
+
87
+
88
+ async def get_list_items(self, list_id: str, type: str = "Media", start_id: str = "0"):
89
+ return await self._request_post("getListItems", {"list_id": list_id, "type": type, "start_id": start_id})
90
+
91
+ async def get_media_by_id(self, media_id: str,track_id:str=None):
92
+ return await self._request_post("getMedia", {"media_id": media_id,"track_id":track_id})
93
+
94
+ async def get_custom_menu_items(self):
95
+ return await self._request_post("getCustomMenuItems", {})
96
+
97
+ async def get_wish_list(self, start_id: Optional[str] = None):
98
+ return await self._request_post("getWishList", {"start_id": start_id})
99
+
100
+ async def get_me(self):
101
+ return await self._request_post("getAccountInfo", {})
102
+
103
+ async def search_video(self, text: str, start_id: Optional[str] = None):
104
+ return await self._request_post("search", {'search_text': text, 'start_id': start_id})
105
+
106
+ async def _action_on_media(self, action: str, media_id: str):
107
+
108
+ return await self._request_post('actionOnMedia', {'action': action, 'media_id': media_id})
109
+
110
+ async def like_media(self, media_id: str):
111
+ return await self._action_on_media("Like", media_id)
112
+
113
+ async def un_like_media(self, media_id: str):
114
+ return await self._action_on_media("Dislike", media_id)
115
+
116
+ async def add_wish_media(self, media_id: str):
117
+ return await self._action_on_media("AddWishList", media_id)
118
+
119
+ async def get_cast_medias(self, cast_id: str, start_id: str = "0"):
120
+ return await self._request_post("getCastMedias", {'cast_id': cast_id, 'start_id': start_id})
121
+
122
+ async def get_cast_info(self, cast_id: str):
123
+ return await self._request_post("getCastDetails", {'cast_id': cast_id})
124
+ async def get_Season_Episodes(self, season_id: str,series_id:str):
125
+ return await self._request_post("getSeasonEpisodes", {'season_id': season_id,"series_id":series_id})
126
+ async def get_Related(self, media_id: str,start_id:str="0"):
127
+ return await self._request_post("getRelated", {'media_id': media_id,"start_id":start_id})
128
+
129
+
130
+ async def close(self):
131
+ await self.client.aclose()
132
+
133
+ async def __aenter__(self):
134
+ return self
135
+
136
+ async def __aexit__(self, exc_type, exc_val, exc_tb):
137
+ await self.close()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Rubka
3
- Version: 6.6.8
3
+ Version: 6.6.10
4
4
  Summary: rubika A Python library for interacting with Rubika Bot API.
5
5
  Home-page: https://github.com/Mahdy-Ahmadi/Rubka
6
6
  Download-URL: https://github.com/Mahdy-Ahmadi/rubka/archive/refs/tags/v6.6.4.zip
@@ -1,4 +1,4 @@
1
- rubka/__init__.py,sha256=U-SYffAzOOgUzfNaO0mSYanFaoYBStHtRI-FCiIpjyM,1941
1
+ rubka/__init__.py,sha256=bFi0O4tBxL64KzNiaAUuYYaVMFmHxj4c9ie_mh-PTyc,1971
2
2
  rubka/api.py,sha256=1S8JIcYN_Zxb7JT73eQl9me-qDDDTDzcSk6_qawAfkA,68861
3
3
  rubka/asynco.py,sha256=MzMhDPM34AdwLUlTaKxzZC7mJ8TLRYkJNAZdZE3KTvk,85535
4
4
  rubka/button.py,sha256=vU9OvWXCD4MRrTJ8Xmivd4L471-06zrD2qpZBTw5vjY,13305
@@ -13,6 +13,7 @@ rubka/keyboards.py,sha256=7nr-dT2bQJVQnQ6RMWPTSjML6EEk6dsBx-4d8pab8xk,488
13
13
  rubka/keypad.py,sha256=yGsNt8W5HtUFBzVF1m_p7GySlu1hwIcSvXZ4BTdrlvg,9558
14
14
  rubka/logger.py,sha256=J2I6NiK1z32lrAzC4H1Et6WPMBXxXGCVUsW4jgcAofs,289
15
15
  rubka/rubino.py,sha256=GuXnEUTTSZUw68FMTQBYsB2zG_3rzdDa-krsrl4ib8w,58755
16
+ rubka/tv.py,sha256=o7CW-6EKLhmM--rzcHcKPcXfzOixcL_B4j037R3mHts,5399
16
17
  rubka/update.py,sha256=4YZs7DiZD_HWOqY76hwwajG0J-bLy6wjeKtQT3EatZU,19341
17
18
  rubka/utils.py,sha256=XUQUZxQt9J2f0X5hmAH_MH1kibTAfdT1T4AaBkBhBBs,148
18
19
  rubka/adaptorrubka/__init__.py,sha256=6o2tCXnVeES7nx-LjnzsuMqjKcWIm9qwKficLE54s-U,83
@@ -36,8 +37,8 @@ rubka/adaptorrubka/types/socket/message.py,sha256=0WgLMZh4eow8Zn7AiSX4C3GZjQTkIg
36
37
  rubka/adaptorrubka/utils/__init__.py,sha256=OgCFkXdNFh379quNwIVOAWY2NP5cIOxU5gDRRALTk4o,54
37
38
  rubka/adaptorrubka/utils/configs.py,sha256=nMUEOJh1NqDJsf9W9PurkN_DLYjO6kKPMm923i4Jj_A,492
38
39
  rubka/adaptorrubka/utils/utils.py,sha256=5-LioLNYX_TIbQGDeT50j7Sg9nAWH2LJUUs-iEXpsUY,8816
39
- rubka-6.6.8.dist-info/METADATA,sha256=lopBqCYnxAD_5VpfPbiBiZfKyraXaAu2fu7osONTUTw,34043
40
- rubka-6.6.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
41
- rubka-6.6.8.dist-info/entry_points.txt,sha256=4aESuUmuUOALMUy7Kucv_Gb5YlqhsJmTmdXLlZU9sJ0,46
42
- rubka-6.6.8.dist-info/top_level.txt,sha256=vy2A4lot11cRMdQS-F4HDCIXL3JK8RKfu7HMDkezJW4,6
43
- rubka-6.6.8.dist-info/RECORD,,
40
+ rubka-6.6.10.dist-info/METADATA,sha256=X78C9eSPhpdUYqGdYchTw0h7gMhPyxGnwcQgTnF2nhk,34044
41
+ rubka-6.6.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
42
+ rubka-6.6.10.dist-info/entry_points.txt,sha256=4aESuUmuUOALMUy7Kucv_Gb5YlqhsJmTmdXLlZU9sJ0,46
43
+ rubka-6.6.10.dist-info/top_level.txt,sha256=vy2A4lot11cRMdQS-F4HDCIXL3JK8RKfu7HMDkezJW4,6
44
+ rubka-6.6.10.dist-info/RECORD,,
File without changes