Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
修复无法使用的问题
Browse files Browse the repository at this point in the history
修复无法使用的问题
  • Loading branch information
Zrincet committed Mar 27, 2021
1 parent 2c6ebc1 commit 1b08cec
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@
from bs4 import BeautifulSoup
import json

__version__ = '0.1.0'
__version__ = '1.0.1'
_LOGGER = logging.getLogger(__name__)

REQUIREMENTS = ['requests', 'beautifulsoup4']

COMPONENT_REPO = 'https://github.com/zrincet/movie_box-office_query/'
SCAN_INTERVAL = timedelta(seconds=120)
SCAN_INTERVAL = timedelta(seconds=600)
CONF_OPTIONS = "options"
CONF_NUM = 'movie_num'
ATTR_UPDATE_TIME = "更新时间"
Expand Down Expand Up @@ -86,7 +84,6 @@ def update(self):
_LOGGER.error("Unable to connect to maoyan site. %s", error)

try:
import time
time_stamp = re_json['movieList']['data']['updateInfo']['updateTimestamp'] / 1000
time_array = time.localtime(time_stamp)
self._updateTime = time.strftime("%Y-%m-%d %H:%M:%S", time_array)
Expand All @@ -98,10 +95,21 @@ def update(self):
tmp_num = self._movieNum
else:
tmp_num = len(list(movie_list))
num_dict = {
'': '0',
'': '1',
'': '2',
'': '3',
'': '3',
'': '5',
'': '6',
'': '8'

}
for i in range(0, tmp_num):
movie_info = {}
movie_info['name'] = movie_list[i]['movieInfo']['movieName']
movie_info['boxUnit'] = float(movie_list[i]['boxSplitUnit']['num'])
# movie_info['boxUnit'] = movie_list[i]['boxSplitUnit']['num']
movie_info['boxRate'] = movie_list[i]['boxRate']
movie_info['showCount'] = movie_list[i]['showCount']
movie_info['showCountRate'] = movie_list[i]['showCountRate']
Expand All @@ -114,7 +122,8 @@ def update(self):
response = request('GET', url_detail, headers=header, params=data)
response.encoding = 'utf-8'
movie_info_detail_json = json.loads(response.text)
movie_info['imgUrl'] = str(movie_info_detail_json['movieInfo']['imgUrl']).replace('w.h/', '')
movie_info['boxUnit'] = float(movie_info_detail_json['data']['boxTrends'][-1]['boxDesc'].replace('万', ''))
movie_info['imgUrl'] = str(movie_info_detail_json['data']['movieInfo']['imgUrl']).replace('w.h/', '').replace("http://", 'https://')
except Exception as e:
_LOGGER.error("Something wrong in movie box-office. with get imgUrl %s", e)

Expand Down

0 comments on commit 1b08cec

Please sign in to comment.