|
|
@@ -44,7 +44,8 @@ def fetch_video_info ( |
|
|
|
|
|
|
|
|
description = (bs.find ('meta', attrs = { 'name': 'description' }) |
|
|
description = (bs.find ('meta', attrs = { 'name': 'description' }) |
|
|
.get ('content')) # type: ignore |
|
|
.get ('content')) # type: ignore |
|
|
except (AttributeError, TypeError): |
|
|
|
|
|
|
|
|
except (AttributeError, TypeError) as ex: |
|
|
|
|
|
print (ex) |
|
|
return None |
|
|
return None |
|
|
|
|
|
|
|
|
return { 'contentId': video_code, |
|
|
return { 'contentId': video_code, |
|
|
@@ -86,15 +87,15 @@ def fetch_embed_info ( |
|
|
if tmp is not None and hasattr (tmp, 'get'): |
|
|
if tmp is not None and hasattr (tmp, 'get'): |
|
|
try: |
|
|
try: |
|
|
description = str (tmp.get ('content')) |
|
|
description = str (tmp.get ('content')) |
|
|
except (AttributeError, TypeError): |
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
except (AttributeError, TypeError) as ex: |
|
|
|
|
|
print (ex) |
|
|
|
|
|
|
|
|
tmp = bs.find ('meta', attrs = { 'name': 'thumbnail' }) |
|
|
tmp = bs.find ('meta', attrs = { 'name': 'thumbnail' }) |
|
|
if tmp is not None and hasattr (tmp, 'get'): |
|
|
if tmp is not None and hasattr (tmp, 'get'): |
|
|
try: |
|
|
try: |
|
|
thumbnail = str (tmp.get ('content')) |
|
|
thumbnail = str (tmp.get ('content')) |
|
|
except (AttributeError, TypeError): |
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
except (AttributeError, TypeError) as ex: |
|
|
|
|
|
print (ex) |
|
|
|
|
|
|
|
|
return (title, description, thumbnail) |
|
|
return (title, description, thumbnail) |
|
|
|
|
|
|
|
|
@@ -133,7 +134,8 @@ def fetch_latest_video ( |
|
|
.find ('li', class_ = 'item')) |
|
|
.find ('li', class_ = 'item')) |
|
|
|
|
|
|
|
|
video_info['contentId'] = video['data-video-id'] |
|
|
video_info['contentId'] = video['data-video-id'] |
|
|
except (AttributeError, IndexError, KeyError, TypeError): |
|
|
|
|
|
|
|
|
except (AttributeError, IndexError, KeyError, TypeError) as ex: |
|
|
|
|
|
print (ex) |
|
|
return None |
|
|
return None |
|
|
|
|
|
|
|
|
return fetch_video_info (video_info['contentId']) |
|
|
return fetch_video_info (video_info['contentId']) |
|
|
@@ -164,7 +166,8 @@ def _create_bs_from_url ( |
|
|
|
|
|
|
|
|
try: |
|
|
try: |
|
|
req = requests.get (url, params = params, timeout = 60) |
|
|
req = requests.get (url, params = params, timeout = 60) |
|
|
except Timeout: |
|
|
|
|
|
|
|
|
except Timeout as ex: |
|
|
|
|
|
print (ex) |
|
|
return None |
|
|
return None |
|
|
|
|
|
|
|
|
if req.status_code != 200: |
|
|
if req.status_code != 200: |
|
|
|