anilibria-api-client 0.1.7__py3-none-any.whl → 0.1.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.
- anilibria_api_client/__init__.py +28 -28
- anilibria_api_client/api_client.py +58 -58
- anilibria_api_client/base_api/api_class.py +283 -283
- anilibria_api_client/exceptions.py +6 -6
- anilibria_api_client/helper.py +100 -100
- anilibria_api_client/methods/__init__.py +5 -5
- anilibria_api_client/methods/_helper.py +225 -225
- anilibria_api_client/methods/_libria.py +9 -9
- anilibria_api_client/methods/accounts.py +348 -348
- anilibria_api_client/methods/ads.py +22 -22
- anilibria_api_client/methods/anime.py +669 -669
- anilibria_api_client/methods/app.py +33 -33
- anilibria_api_client/methods/media.py +44 -44
- anilibria_api_client/methods/teams.py +60 -60
- anilibria_api_client/models.py +63 -63
- anilibria_api_client/types.py +55 -55
- {anilibria_api_client-0.1.7.dist-info → anilibria_api_client-0.1.8.dist-info}/METADATA +83 -71
- anilibria_api_client-0.1.8.dist-info/RECORD +21 -0
- {anilibria_api_client-0.1.7.dist-info → anilibria_api_client-0.1.8.dist-info}/licenses/LICENSE +21 -21
- anilibria_api_client-0.1.7.dist-info/RECORD +0 -21
- {anilibria_api_client-0.1.7.dist-info → anilibria_api_client-0.1.8.dist-info}/WHEEL +0 -0
- {anilibria_api_client-0.1.7.dist-info → anilibria_api_client-0.1.8.dist-info}/top_level.txt +0 -0
anilibria_api_client/helper.py
CHANGED
@@ -1,100 +1,100 @@
|
|
1
|
-
import m3u8_To_MP4
|
2
|
-
import os # Path / Makedir
|
3
|
-
import aiofiles
|
4
|
-
|
5
|
-
from .api_client import AsyncAnilibriaAPI
|
6
|
-
from .exceptions import AnilibriaException
|
7
|
-
|
8
|
-
from ffmpeg.asyncio import FFmpeg
|
9
|
-
|
10
|
-
|
11
|
-
async def auth(api: AsyncAnilibriaAPI, login: str, password: str) -> AsyncAnilibriaAPI:
|
12
|
-
"""
|
13
|
-
Используется для простой авторизации без использования методов одной строчкой
|
14
|
-
|
15
|
-
:param api: AsyncAnilibriaAPI
|
16
|
-
:param login: Логин от ЛК Anilibria
|
17
|
-
:param password: Пароль от ЛК Anilibria
|
18
|
-
:return: AsyncAnilibriaAPI
|
19
|
-
"""
|
20
|
-
try:
|
21
|
-
res = await api.accounts.users_auth_login(login=login, password=password)
|
22
|
-
|
23
|
-
return AsyncAnilibriaAPI(authorization=f"Bearer {res.get("token")}")
|
24
|
-
except AnilibriaException as e:
|
25
|
-
raise AnilibriaException("Auth error!")
|
26
|
-
|
27
|
-
async def async_download(url: str, output_path: str = None, filename: str = "output.mp4"):
|
28
|
-
"""
|
29
|
-
Позволяет скачивать серию через URL (https://cache-rfn.libria.fun/videos/media/)
|
30
|
-
ffmpeg required
|
31
|
-
|
32
|
-
:param url: Ссылка на m3u8 плейлист
|
33
|
-
:param output_path: Полный путь к выходному файлу (включая имя файла и расширение .mp4)
|
34
|
-
"""
|
35
|
-
if output_path is None:
|
36
|
-
mp4_file_dir = os.getcwd()
|
37
|
-
mp4_file_name = filename
|
38
|
-
else:
|
39
|
-
mp4_file_dir = os.path.dirname(output_path)
|
40
|
-
mp4_file_name = os.path.basename(output_path)
|
41
|
-
|
42
|
-
if not mp4_file_dir:
|
43
|
-
mp4_file_dir = os.getcwd()
|
44
|
-
|
45
|
-
if not os.path.exists(mp4_file_dir):
|
46
|
-
os.makedirs(mp4_file_dir, exist_ok=True)
|
47
|
-
|
48
|
-
return m3u8_To_MP4.multithread_download(
|
49
|
-
m3u8_uri=url,
|
50
|
-
mp4_file_dir=mp4_file_dir,
|
51
|
-
mp4_file_name=mp4_file_name
|
52
|
-
)
|
53
|
-
|
54
|
-
async def async_ffmpeg_download(url: str, output_path: str) -> bool:
|
55
|
-
"""
|
56
|
-
Скачивание m3u8 через ffmpeg с обходом блокировок (при блокировки основного метода async_download)
|
57
|
-
|
58
|
-
Может быть медленным, используйте хороший интернет
|
59
|
-
|
60
|
-
:param url: Ссылка
|
61
|
-
:param output_path: Путь для сохранения MP4 файла
|
62
|
-
:return: bool
|
63
|
-
"""
|
64
|
-
try:
|
65
|
-
ffmpeg = (
|
66
|
-
FFmpeg()
|
67
|
-
.input(url)
|
68
|
-
.output(output_path, **{
|
69
|
-
"vcodec": "libx264",
|
70
|
-
"crf": 27,
|
71
|
-
"preset": "veryfast",
|
72
|
-
"c:a": "copy",
|
73
|
-
"bsf:a": "aac_adtstoasc"
|
74
|
-
}
|
75
|
-
)
|
76
|
-
)
|
77
|
-
await ffmpeg.execute()
|
78
|
-
return True
|
79
|
-
|
80
|
-
except KeyError:
|
81
|
-
return "Запрашиваемое видео недоступно."
|
82
|
-
except ValueError:
|
83
|
-
return "Неверная ссылка."
|
84
|
-
except Exception as e:
|
85
|
-
return "Произошла непредвиденная ошибка при загрузке видео: " + str(e)
|
86
|
-
|
87
|
-
async def download_torrent_file(torrent_bytes: bytes, filename: str):
|
88
|
-
"""
|
89
|
-
Асинхронно сохраняет .torrent файл
|
90
|
-
|
91
|
-
:param torrent_bytes: бинарные данные torrent-файла
|
92
|
-
:param filename: имя файла
|
93
|
-
"""
|
94
|
-
if not filename.endswith('.torrent'):
|
95
|
-
filename += '.torrent'
|
96
|
-
|
97
|
-
async with aiofiles.open(filename, 'wb') as f:
|
98
|
-
await f.write(torrent_bytes)
|
99
|
-
|
100
|
-
return True
|
1
|
+
import m3u8_To_MP4
|
2
|
+
import os # Path / Makedir
|
3
|
+
import aiofiles
|
4
|
+
|
5
|
+
from .api_client import AsyncAnilibriaAPI
|
6
|
+
from .exceptions import AnilibriaException
|
7
|
+
|
8
|
+
from ffmpeg.asyncio import FFmpeg
|
9
|
+
|
10
|
+
|
11
|
+
async def auth(api: AsyncAnilibriaAPI, login: str, password: str) -> AsyncAnilibriaAPI:
|
12
|
+
"""
|
13
|
+
Используется для простой авторизации без использования методов одной строчкой
|
14
|
+
|
15
|
+
:param api: AsyncAnilibriaAPI
|
16
|
+
:param login: Логин от ЛК Anilibria
|
17
|
+
:param password: Пароль от ЛК Anilibria
|
18
|
+
:return: AsyncAnilibriaAPI
|
19
|
+
"""
|
20
|
+
try:
|
21
|
+
res = await api.accounts.users_auth_login(login=login, password=password)
|
22
|
+
|
23
|
+
return AsyncAnilibriaAPI(authorization=f"Bearer {res.get("token")}")
|
24
|
+
except AnilibriaException as e:
|
25
|
+
raise AnilibriaException("Auth error!")
|
26
|
+
|
27
|
+
async def async_download(url: str, output_path: str = None, filename: str = "output.mp4"):
|
28
|
+
"""
|
29
|
+
Позволяет скачивать серию через URL (https://cache-rfn.libria.fun/videos/media/)
|
30
|
+
ffmpeg required
|
31
|
+
|
32
|
+
:param url: Ссылка на m3u8 плейлист
|
33
|
+
:param output_path: Полный путь к выходному файлу (включая имя файла и расширение .mp4)
|
34
|
+
"""
|
35
|
+
if output_path is None:
|
36
|
+
mp4_file_dir = os.getcwd()
|
37
|
+
mp4_file_name = filename
|
38
|
+
else:
|
39
|
+
mp4_file_dir = os.path.dirname(output_path)
|
40
|
+
mp4_file_name = os.path.basename(output_path)
|
41
|
+
|
42
|
+
if not mp4_file_dir:
|
43
|
+
mp4_file_dir = os.getcwd()
|
44
|
+
|
45
|
+
if not os.path.exists(mp4_file_dir):
|
46
|
+
os.makedirs(mp4_file_dir, exist_ok=True)
|
47
|
+
|
48
|
+
return m3u8_To_MP4.multithread_download(
|
49
|
+
m3u8_uri=url,
|
50
|
+
mp4_file_dir=mp4_file_dir,
|
51
|
+
mp4_file_name=mp4_file_name
|
52
|
+
)
|
53
|
+
|
54
|
+
async def async_ffmpeg_download(url: str, output_path: str) -> bool:
|
55
|
+
"""
|
56
|
+
Скачивание m3u8 через ffmpeg с обходом блокировок (при блокировки основного метода async_download)
|
57
|
+
|
58
|
+
Может быть медленным, используйте хороший интернет
|
59
|
+
|
60
|
+
:param url: Ссылка
|
61
|
+
:param output_path: Путь для сохранения MP4 файла
|
62
|
+
:return: bool
|
63
|
+
"""
|
64
|
+
try:
|
65
|
+
ffmpeg = (
|
66
|
+
FFmpeg()
|
67
|
+
.input(url)
|
68
|
+
.output(output_path, **{
|
69
|
+
"vcodec": "libx264",
|
70
|
+
"crf": 27,
|
71
|
+
"preset": "veryfast",
|
72
|
+
"c:a": "copy",
|
73
|
+
"bsf:a": "aac_adtstoasc"
|
74
|
+
}
|
75
|
+
)
|
76
|
+
)
|
77
|
+
await ffmpeg.execute()
|
78
|
+
return True
|
79
|
+
|
80
|
+
except KeyError:
|
81
|
+
return "Запрашиваемое видео недоступно."
|
82
|
+
except ValueError:
|
83
|
+
return "Неверная ссылка."
|
84
|
+
except Exception as e:
|
85
|
+
return "Произошла непредвиденная ошибка при загрузке видео: " + str(e)
|
86
|
+
|
87
|
+
async def download_torrent_file(torrent_bytes: bytes, filename: str):
|
88
|
+
"""
|
89
|
+
Асинхронно сохраняет .torrent файл
|
90
|
+
|
91
|
+
:param torrent_bytes: бинарные данные torrent-файла
|
92
|
+
:param filename: имя файла
|
93
|
+
"""
|
94
|
+
if not filename.endswith('.torrent'):
|
95
|
+
filename += '.torrent'
|
96
|
+
|
97
|
+
async with aiofiles.open(filename, 'wb') as f:
|
98
|
+
await f.write(torrent_bytes)
|
99
|
+
|
100
|
+
return True
|
@@ -1,6 +1,6 @@
|
|
1
|
-
from .accounts import AccountsMethod
|
2
|
-
from .ads import AdsMethod
|
3
|
-
from .anime import AnimeMethod
|
4
|
-
from .app import AppMethod
|
5
|
-
from .media import MediaMethod
|
1
|
+
from .accounts import AccountsMethod
|
2
|
+
from .ads import AdsMethod
|
3
|
+
from .anime import AnimeMethod
|
4
|
+
from .app import AppMethod
|
5
|
+
from .media import MediaMethod
|
6
6
|
from .teams import TeamsMethod
|