source: titan/mediathek/localhoster/vshare.py

Last change on this file was 44498, checked in by obi, 2 years ago

add lost file

File size: 9.7 KB
Line 
1
2import re, time
3from lib import jsunpack
4import sys
5from lib.net import Net
6import lib.common as common
7import urllib2
8from lib import helpers
9
10class VshareResolver(object):
11    name = "flashx"
12    domains = ["flashx.tv"]
13    pattern = '(?://|\.)(flashx\.net|flashx\.tv)/(?:embed-|dl\?|embed.php\?c=)?([0-9a-zA-Z/-]+)'
14
15    def __init__(self):
16        self.net = Net()
17        url = str(sys.argv[1])
18        return self.get_media_url(url)
19
20    def isValidUrl(self, url):
21        return url.startswith('http://') or url.startswith('https://')
22
23    def getDataBeetwenMarkers(self, data, marker1, marker2, withMarkers=True, caseSensitive=True):
24        if caseSensitive:
25            idx1 = data.find(marker1)
26        else:
27            idx1 = data.lower().find(marker1.lower())
28        if -1 == idx1: return False, ''
29        if caseSensitive:
30            idx2 = data.find(marker2, idx1 + len(marker1))
31        else:
32            idx2 = data.lower().find(marker2.lower(), idx1 + len(marker1))
33        if -1 == idx2: return False, ''
34       
35        if withMarkers:
36            idx2 = idx2 + len(marker2)
37        else:
38            idx1 = idx1 + len(marker1)
39
40        return True, data[idx1:idx2]
41
42        # edit bb , touch commands.getouput with this def #
43
44    def getAllItemsBeetwenMarkers(self, data, marker1, marker2, withMarkers=True, caseSensitive=True):
45        itemsTab = []
46        if caseSensitive:
47            sData = data
48        else:
49            sData = data.lower()
50            marker1 = marker1.lower()
51            marker2 = marker2.lower()
52        idx1 = 0
53        while True:
54            idx1 = sData.find(marker1, idx1)
55            if -1 == idx1: return itemsTab
56            idx2 = sData.find(marker2, idx1 + len(marker1))
57            if -1 == idx2: return itemsTab
58            tmpIdx2 = idx2 + len(marker2)
59            if withMarkers:
60                idx2 = tmpIdx2
61            else:
62                idx1 = idx1 + len(marker1)
63            itemsTab.append(data[idx1:idx2])
64            idx1 = tmpIdx2
65        return itemsTab
66
67    def getSearchGroups(self, data, pattern, grupsNum=1, ignoreCase=False):
68        tab = []
69        if ignoreCase:
70            match = re.search(pattern, data, re.IGNORECASE)
71        else:
72            match = re.search(pattern, data)
73       
74        for idx in range(grupsNum):
75            try:    value = match.group(idx + 1)
76            except Exception: value = ''
77            tab.append(value)
78        return tab
79
80    def __getJS(self, data, params):
81        tmpUrls = re.compile("""<script[^>]+?src=['"]([^'^"]+?)['"]""", re.IGNORECASE).findall(data)
82#        print "tmpUrls: ", tmpUrls
83        codeUrl = 'https://www.flashx.tv/js/code.js'
84        for tmpUrl in tmpUrls:
85#            print "tmpUrl: ", tmpUrl
86
87            if tmpUrl.startswith('.'):
88                tmpUrl = tmpUrl[1:]
89            if tmpUrl.startswith('//'):
90                tmpUrl = 'https:' + tmpUrl
91            if tmpUrl.startswith('/'):
92                tmpUrl = 'https://www.flashx.tv' + tmpUrl
93            if self.isValidUrl(tmpUrl):
94                if ('flashx' in tmpUrl and 'jquery' not in tmpUrl and '/code.js' not in tmpUrl and '/coder.js' not in tmpUrl):
95#                    print '$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'
96                    #sts, tmp = self.cm.getPage(tmpUrl.replace('\n', ''), params)
97                   
98                    try: tmp = self.net.http_GET(tmpUrl.replace('\n', ''), params).content
99                    except: pass
100                elif '/code.js' in tmpUrl or '/coder.js' in tmpUrl:
101                    codeUrl = tmpUrl
102           
103#        sts, tmp = self.cm.getPage(codeUrl, params)
104        tmp = self.net.http_GET(codeUrl, params).content
105        tmp = self.getAllItemsBeetwenMarkers(tmp, 'function', ';');
106        for tmpItem in tmp:
107            tmpItem = tmpItem.replace(' ', '')
108            if '!=null' in tmpItem:
109                tmpItem   = self.getDataBeetwenMarkers(tmpItem, 'get(', ')')[1]
110                tmpUrl    = self.getSearchGroups(tmpItem, """['"](https?://[^'^"]+?)['"]""")[0]
111                if not self.isValidUrl(tmpUrl): continue
112                getParams = self.getDataBeetwenMarkers(tmpItem, '{', '}', False)[1]
113                getParams = getParams.replace(':', '=').replace(',', '&').replace('"', '').replace("'", '')
114                tmpUrl += '?' + getParams
115#                sts, tmp = self.cm.getPage(tmpUrl, params)
116                tmp = self.net.http_GET(tmpUrl, params).content
117                break
118
119    def get_media_url(self, url):
120
121        resp = self.net.http_GET(url)
122        html = resp.content
123
124        if re.search('>Security Check<', html):
125            print 'errormsg=Too many views per minute. We think you are a spider, crawler, ddoser or something'
126            return
127
128#<Center>
129#<b><font color="red">Security Check</font></b><br><br>
130#<br><br>
131#Too many views per minute. We think you are a spider, crawler, ddoser or something else.<br>
132#If you are human, please contact <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="fd9c9f888e9889989c90bd9b919c8e95a5d3898b">[email&#160;protected]</a> and <b>whitelist</b> your IP (91.137.28.121).<br>
133#Or try it again a little bit later.
134#<br><br>
135#<center>
136#<a href="http://trk.globwo.online/377b640b-3ab1-4b42-acec-3b6ff8ef1a2e" target="_blank"><img src="https://static.flashx.net/img/player.png" border="0"></a>
137#</center>
138
139#        print "# 1 start ##########################"
140#        print html
141#        print "# 1 end ##########################"
142
143#       return
144#        cfdcookie = resp._response.info()['set-cookie']
145#        cfduid = re.search('cfduid=(.*?);', cfdcookie).group(1)
146#        file_id = re.search("'file_id', '(.*?)'", html).group(1)
147#        aff = re.search("'aff', '(.*?)'", html).group(1)
148        headers = {'User-Agent': common.IE_USER_AGENT,
149                   'Referer': url}
150
151#        surl = re.search('src="(.*?' + file_id + ')', html, re.IGNORECASE).group(1)
152#        dummy = self.net.http_GET(url=surl, headers=headers).content
153        headers = {'User-Agent': common.IE_USER_AGENT,
154                   'Referer': url}
155        html = self.net.http_GET(url=url, headers=headers).content
156
157        fname = re.search('name="fname" value="(.*?)"', html).group(1)
158#        hash = re.search('name="hash" value="(.*?)"', html).group(1)
159        id = re.search('name="id" value="(.*?)"', html).group(1)
160        method_free = re.search('name="method_free" value="(.*?)"', html).group(1)
161#        action = re.search('method="POST" action="(.*?)"', html).group(1)
162        fdata = {'op': 'download1',
163                 'usr_login': '',
164                 'id': id,
165                 'fname': fname,
166                 'referer': '',
167                 'method_free': method_free}
168#                 'imhuman': 'Proceed to video'
169#        furl = 'http://www.flashx.tv/dl'# + media_id
170#                <Form method="POST" action='' class="center">
171#                    <input type="hidden" name="op" value="download1">
172#                    <input type="hidden" name="usr_login" value="">
173#                    <input type="hidden" name="id" value="zg5c3tovyst1">
174#                    <input type="hidden" name="fname" value="Hackers 2 Operation Takedown-kinox.to(575)-bySGexx.mp4.mp4">
175#                    <input type="hidden" name="referer" value="">
176#                    <input class="large button strong proceed" id="play" style="outline: none; width: 200px" type="submit" name="method_free" value="Proceed to video">
177#                </Form>
178
179#        sleeptime = re.search('>([0-9])</span> seconds<', html).group(1)
180#        print "action: ", action
181#        print "fdata: ", fdata
182#op=download1&usr_login=&id=zg5c3tovyst1&fname=Hackers+2+Operation+Takedown-kinox.to%28575%29-bySGexx.mp4.mp4&referer=&method_free=Proceed+to+video
183#<source src="https://vs096.vshare.eu:182/d/baemfeil7hnroluvocdqwo7wa6h4ufqgjdeesgubqcd6wm6xrz2o26bh/vid.mp4" type="video/mp4">
184
185#        print "headers: ", headers
186
187#        print "sleeptime", sleeptime
188
189        self.__getJS(html, headers)
190
191        time.sleep(8)
192        html = self.net.http_POST(url=url, form_data=fdata, headers=headers).content
193#        print "# 2 start ##########################"
194#        print html
195#        print "# 2 end ##########################"
196
197        js_data = re.findall('(eval\(function.*?)</script>', html.replace('\n', ''))
198#        print "# 3 start ##########################"
199#        print js_data
200#        print "# 3 end ##########################"
201
202        for i in js_data:
203            try: html += jsunpack.unpack(i)
204            except: pass
205
206#        print "# 3 start ##########################"
207#        print html
208#        print "# 3 end ##########################"
209
210# <center><font size="4">You try to access the video with Kodi / XBMC / TV BOX or AdBlock.<br><br>
211# <font color="red">This is prohibited!</font></font><br><br><br>
212# <font size="2">If we made a mistake, please <a href="https://www.flashx.net/contact.html" target="_blank">contact us via contact form</a>!<br>
213# Or disable your <b>adblock addon</b> and try again.<br><br>
214# Or try to reload the page! <a href="https://www.flashx.net/reloadit.php?w=d&c=20988890&i=zsy14viyeh2j">!! <b><font color="red">Click here</font></b> !!</a><br><br></font></center>
215# <br><br>
216
217        if re.search('>You try to access the video with Kodi / XBMC / TV BOX or AdBlock.<', html):
218            print 'errormsg=You try to access the video with Kodi / XBMC / TV BOX or AdBlock.'
219            return
220
221#<source src="https://vs096.vshare.eu:182/d/baemfeil7hnroluvocdqwo7wa6h4ufqgjdeesgubqcd6wm6xryzfmrfx/vid.mp4" type="video/mp4">
222        #{src: 'https://flashx1.tv/cdn107/5k7x22t6vivfjuw5lwxyzw2fsdqgparrhy55dd75c464tmacqfoh7ooeg7mq/normal.mp4',type: 'video/mp4',label: 'SD',res: 360},
223
224        print re.search('<source src="([^"].*)" type', html).group(1)
225                 
226sys.stdout = VshareResolver()
Note: See TracBrowser for help on using the repository browser.