26 lines
907 B
Python
26 lines
907 B
Python
import requests
|
|
import json
|
|
|
|
from . import API_URL
|
|
from .auth import AuthAPI
|
|
|
|
class RawAPI():
|
|
def updateByAttrs(channel, id, attrs = None):
|
|
try:
|
|
ret = requests.post(API_URL + 'api/file/raw/update/' + str(channel) + '/' + str(id), attrs, headers= self._header, timeout = 3)
|
|
if ret.status_code == 200:
|
|
return True
|
|
except requests.exceptions.ConnectionError as e:
|
|
print('update raw by attrs fail', e)
|
|
return False
|
|
|
|
def getByChannelID(channel, id):
|
|
try:
|
|
ret = requests.get(API_URL + 'api/file/raw/get_by_id/' + str(channel) + '/' + str(id), headers= AuthAPI.get_key())
|
|
if ret.status_code == 200:
|
|
return ret.json()
|
|
except (requests.exceptions.ConnectionError, json.decoder.JSONDecodeError) as e:
|
|
print('get raw by channel id fail', e)
|
|
return False
|
|
|
|
|