Skip to content

Commit

Permalink
fix Uptobox resolver (jsergio123#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gujal00 committed Mar 24, 2020
1 parent 5b99bce commit be85dc3
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions lib/resolveurl/plugins/uptobox.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Copyright (C) 2014 smokdpi
plugin for ResolveURL
Copyright (C) 2020 gujal
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -14,14 +15,35 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import re
import json
from lib import helpers
from resolveurl import common
from resolveurl.resolver import ResolveUrl, ResolverError

from __resolve_generic__ import ResolveGeneric


class UpToBoxResolver(ResolveGeneric):
class UpToBoxResolver(ResolveUrl):
name = "uptobox"
domains = ["uptobox.com", "uptostream.com"]
pattern = '(?://|\.)(uptobox.com|uptostream.com)/(?:iframe/)?([0-9A-Za-z_]+)'
pattern = r'(?://|\.)(uptobox.com|uptostream.com)/(?:iframe/)?([0-9A-Za-z_]+)'

def __init__(self):
self.net = common.Net()

def get_media_url(self, host, media_id):
web_url = self.get_url(host, media_id)
headers = {'User-Agent': common.FF_USER_AGENT}
html = self.net.http_GET(web_url, headers=headers).content

if 'Not Found' in html:
raise ResolverError('File Removed')

packed = re.search(r"atob\('([^']+)", html)
if packed:
vidurl = json.loads(packed.group(1).decode('base64'))[0].get('src')
return vidurl + helpers.append_headers(headers)

raise ResolverError('Video not found')

def get_url(self, host, media_id):
return self._default_get_url(host, media_id, template='https://uptostream.com/iframe/{media_id}')

0 comments on commit be85dc3

Please sign in to comment.