Skip to content

Commit

Permalink
删除 get_share_link_download_url & 添加 get_share_link_video_preview_play…
Browse files Browse the repository at this point in the history
…_info(具有完整的m3u8, 可直接播放)

获取分享文件下载链接功能已被官方下线, 请使用其他方式下载文件
  • Loading branch information
lemisky committed Mar 5, 2024
1 parent 51354f2 commit 3136490
Showing 7 changed files with 84 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/aligo/apis/Share.py
Original file line number Diff line number Diff line change
@@ -401,6 +401,7 @@ def get_share_link_download_url(
**kwargs
) -> GetShareLinkDownloadUrlResponse:
"""get_share_link_download_url"""
raise NotImplementedError('`get_share_link_download_url` 已失效')
_deprecation_warning(kwargs)
if body is None:
body = GetShareLinkDownloadUrlRequest(share_id=share_token.share_id, file_id=file_id, **kwargs)
@@ -603,3 +604,13 @@ def private_share_files(self, file_id_list: List[str], drive_id: str = None):
for file_id in file_id_list
]
))

def get_share_link_video_preview_play_info(
self,
file_id: str,
drive_id: str,
x_share_token: GetShareTokenResponse,
**kwargs,
) -> GetShareLinkVideoPreviewPlayInfoResponse:
body = GetShareLinkVideoPreviewPlayInfoRequest(file_id, drive_id, x_share_token.share_id, **kwargs)
return self._core_get_share_link_video_preview_play_info(body, x_share_token)
1 change: 1 addition & 0 deletions src/aligo/core/Config.py
Original file line number Diff line number Diff line change
@@ -92,6 +92,7 @@
ADRIVE_V2_FILE_LIST_BY_SHARE = '/adrive/v2/file/list_by_share'
ADRIVE_V2_FILE_GET_BY_SHARE = '/adrive/v2/file/get_by_share'
ADRIVE_V1_SHARE_CREATE = '/adrive/v1/share/create'
V2_FILE_GET_SHARE_LINK_VIDEO_PREVIEW_PLAY_INFO = '/v2/file/get_share_link_video_preview_play_info'

# 批量操作
V3_BATCH = '/v3/batch'
13 changes: 13 additions & 0 deletions src/aligo/core/Share.py
Original file line number Diff line number Diff line change
@@ -134,6 +134,7 @@ def _core_get_share_link_download_url(
x_share_token: GetShareTokenResponse
) -> GetShareLinkDownloadUrlResponse:
"""..."""
raise NotImplementedError('获取分享文件下载链接功能已被官方下线, 请使用其他方式下载文件')
response = self._auth.post(
V2_FILE_GET_SHARE_LINK_DOWNLOAD_URL,
body=body.to_dict(),
@@ -212,3 +213,15 @@ def _core_search_share_files(self, body: SearchShareFileRequest, share_token) ->
def _core_private_share_files(self, body: PrivateShareRequest) -> PrivateShareResponse:
response = self.post(ADRIVE_V1_SHARE_CREATE, body=body)
return self._result(response, PrivateShareResponse)

def _core_get_share_link_video_preview_play_info(
self,
body: GetShareLinkVideoPreviewPlayInfoRequest,
x_share_token: GetShareTokenResponse
) -> GetShareLinkVideoPreviewPlayInfoResponse:
response = self.post(
V2_FILE_GET_SHARE_LINK_VIDEO_PREVIEW_PLAY_INFO,
body=body,
headers={'x-share-token': x_share_token}
)
return self._result(response, GetShareLinkVideoPreviewPlayInfoResponse)
18 changes: 18 additions & 0 deletions src/aligo/request/GetShareLinkVideoPreviewPlayInfoRequest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""..."""
from dataclasses import dataclass

from aligo.types import DatClass


@dataclass
class GetShareLinkVideoPreviewPlayInfoRequest(DatClass):
"""..."""
file_id: str
drive_id: str
share_id: str
category: str = 'live_transcoding'
get_preview_url: bool = True
get_subtitle_info: bool = True
mode: str = 'high_res'
template_id: str = ''
url_expire_sec: int = 600
1 change: 1 addition & 0 deletions src/aligo/request/__init__.py
Original file line number Diff line number Diff line change
@@ -35,6 +35,7 @@
from .GetShareInfoRequest import GetShareInfoRequest
from .GetShareLinkDownloadUrlRequest import GetShareLinkDownloadUrlRequest
from .GetShareLinkListRequest import GetShareLinkListRequest
from .GetShareLinkVideoPreviewPlayInfoRequest import GetShareLinkVideoPreviewPlayInfoRequest
from .GetShareTokenRequest import GetShareTokenRequest
from .GetStarredListRequest import GetStarredListRequest
from .GetUploadUrlRequest import GetUploadUrlRequest
39 changes: 39 additions & 0 deletions src/aligo/response/GetShareLinkVideoPreviewPlayInfoResponse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from dataclasses import dataclass, field
from typing import List

from aligo.types import DatClass


@dataclass
class LiveTranscodingTaskList(DatClass):
keep_original_resolution: bool = None
preview_url: str = None
stage: str = None
status: str = None
template_height: int = None
template_id: str = None
template_name: str = None
template_width: int = None
url: str = None


@dataclass
class Meta(DatClass):
duration: float = None
height: int = None
width: int = None


@dataclass
class VideoPreviewPlayInfo(DatClass):
category: str = None
live_transcoding_task_list: List[LiveTranscodingTaskList] = field(default_factory=list)
meta: Meta = None


@dataclass
class GetShareLinkVideoPreviewPlayInfoResponse(DatClass):
category: str = None
file_id: str = None
share_id: str = None
video_preview_play_info: VideoPreviewPlayInfo = None
1 change: 1 addition & 0 deletions src/aligo/response/__init__.py
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@
from .GetShareInfoResponse import GetShareInfoResponse
from .GetShareLinkDownloadUrlResponse import GetShareLinkDownloadUrlResponse
from .GetShareLinkListResponse import GetShareLinkListResponse
from .GetShareLinkVideoPreviewPlayInfoResponse import GetShareLinkVideoPreviewPlayInfoResponse
from .GetShareTokenResponse import GetShareTokenResponse
from .GetStarredListResponse import GetStarredListResponse
from .GetUploadUrlResponse import GetUploadUrlResponse

0 comments on commit 3136490

Please sign in to comment.