remade gcloud extractor with regex

should be more robust now
master
Blatzar 2020-06-14 22:19:50 +00:00 committed by GitHub
parent 67e6f5e715
commit da091b7869
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 12 deletions

View File

@ -9,20 +9,16 @@ logger = logging.getLogger(__name__)
class Gcloud(BaseExtractor):
def _get_data(self):
url = self.url
logger.debug('Gcloud url: {}'.format(self.url)) #Surprisingly not debug printed in anime.py
"""gcloud uses the same video ID as other sites"""
url = url.replace('fembed.com','gcloud.live')
url = url.replace('feurl.com','gcloud.live')
url = url.replace('gcloud.live/v/','gcloud.live/api/source/')
id_regex = r'(gcloud\.live|fembed\.com|feurl\.com)/(v|api/source)/([^(?|#)]*)' #Group 3 for id
gcloud_id = re.search(id_regex,self.url)
if not gcloud_id:
logger.error('Unable to get ID for url "{}"'.format(self.url))
return {'stream_url': ''}
if url.find('#') != -1: #cuts off the # at the end, used for subtitles
url = url[:url.find('#')]
#Returns the last non-empty string from url (separated with /), which is the id
source_id = list(filter(lambda x: x, url.split('/')[::-1]))[0]
data = helpers.post(f'https://gcloud.live/api/source/{source_id}').json()['data']
gcloud_id = gcloud_id.group(3)
data = helpers.post(f'https://gcloud.live/api/source/{gcloud_id}').json()['data']
if data == 'Video not found or has been removed':
logger.warning('File not found (Most likely deleted)')