Streamsb
1.0.0
Pip package coming Soon
導入客戶端類別並建立 Client 對象,它需要一個 Api Key 作為其唯一參數。您可以從 Streamsb 網站取得 API 金鑰
from streamsb import Client
client = Client ( 'Your_API_Key' )
Client類別主要有四種不同功能的屬性
每個方法呼叫都會傳回一個具有「raw」屬性的對象,如果請求成功,則該屬性包含請求的 json 回應。
acc_info = client . account . info ()
acc_info
# AccountInfo Object, which may contain the following attributes.
{
"raw" : "It contains raw API response of this AccountInfo Object."
"email" : "[email protected]" ,
"balance" : "0.00000" ,
"storage_used" : "24186265" ,
"storage_left" : 128824832615 ,
"premim_expire" : " 2020 - 01 - 20 21 : 00 : 00
}
它將傳回一個 AccountInfo 對象,該物件具有「raw」屬性,其中包含請求的 json 回應。該物件的所有其他屬性都是“raw['result']”中的值。
acc_stats = client . account . stats ()
acc_stats . stats
# List of Stat objects
# Attributes of Stat object can be
{
"raw" : "It contains raw API response of this Stat Object."
"downloads" : "0" ,
"profit_views" : "0.00000" ,
"views_adb" : "1" ,
"sales" : "0" ,
"profit_sales" : "0.00000" ,
"profit_refs" : "0.00000" ,
"profit_site" : "0.00000" ,
"views" : "0" ,
"refs" : "0" ,
"day" : "2020-08-01" ,
"profit_total" : "0.00000" ,
"views_prem" : "0"
}
它將傳回一個 AccountStat 對象,其 stats 屬性是 Stat 物件的清單。每個 stat 物件包含請求的原始 json 回應以及回應的所有屬性。
file = client . file . info ( filecode = "File code" )
file
# List of FileInfo objects which may contain attributes.
{
"raw" : "raw json response"
"status" : 200
" filecode ": " jthi5jdsu8t9 "
" last_download ": datetime . datetime object
" canplay ": bool value
" public ": bool value
" length ": duration of file ( int )
" title ": " File Title "
" views ": " file views ( int )
" name ": " file name ( str ) "
" created ": datetime . datetime Object
#These fields are not document but seen in some responses.
" full_views ": ( int )
" cat_id ": " category id ( int ) "
" player_img ": " video player image ( str )
它將傳回 FileInfo 物件的列表,每個物件可能包含上述屬性。
response = client . file . rename ( filecode = "File code" , title = "New Title" , name = "New name" [ optional ])
response
# Returns True if response is successful otherwise raises APIResponse error.
file = client . file . clone ( filecode = "File Code" )
file
# Returns a File object.
{
"raw" : "raw Json response"
"filecode" : "file code"
"url" : "streamsb url of file"
}
它傳回一個可能包含上述屬性的 File 物件。
files = client . file . list ( filter = {}[ optional ])
# Filter is a dict which may have following keys
{
"title" : "title to look for"
"page" : " page no . for pagination :
"per_page" : "no. of items per page"
"folder_id" : "folder id"
"public" : True to list public files , False for private
" created ": datetime . datetime object
}
qualities = client . file . direct_all ( filecode = "file code" )
qualities
# Returns a dict of Quality object
# each dict key can have values ['l','n','h','o']
{
"l" : Quality (),
"n" : Quality ()
}
# Each Quality object has attributes
{
raw : "raw json response"
url : "url of video"
size : "size of video (int)"
}