Changeset 44496
- Timestamp:
- 01/05/20 20:51:48 (2 years ago)
- Location:
- titan/mediathek/localhoster
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
titan/mediathek/localhoster/flashx.py
r44494 r44496 6 6 import lib.common as common 7 7 import urllib2 8 from lib import helpers 8 9 9 10 class FlashxResolver(object): 10 11 name = "flashx" 11 12 domains = ["flashx.tv"] 12 pattern = '(?://|\.)(flashx\. tv)/(?:embed-|dl\?|embed.php\?c=)?([0-9a-zA-Z/-]+)'13 pattern = '(?://|\.)(flashx\.net|flashx\.tv)/(?:embed-|dl\?|embed.php\?c=)?([0-9a-zA-Z/-]+)' 13 14 14 15 def __init__(self): … … 17 18 return self.get_media_url(url) 18 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 19 119 def get_media_url(self, url): 20 html = self.net.http_GET(url).content 120 if not url.endswith('.jsp') and url.endswith('.html'): 121 if '.tv/embed-' not in url: 122 url = url.replace('.tv/', '.tv/embed-') 123 if not url.endswith('.html'): 124 url += '.html' 125 126 # print "url", url 127 resp = self.net.http_GET(url) 128 html = resp.content 129 130 cfdcookie = resp._response.info()['set-cookie'] 131 cfduid = re.search('cfduid=(.*?);', cfdcookie).group(1) 132 headers = {'User-Agent': common.IE_USER_AGENT, 133 'Referer': url, 134 'Cookie': '__cfduid=' + cfduid + '; lang=1'} 135 136 self.__getJS(html, headers) 137 138 #<input type="image" src="https://static.flashx.net/exp/playnow.png" onclick="location.href='https://www.flashx.net/playvideo-619d0419488c19e5216f83b2e010f3df.html?playvid'" style="margin-left:auto;margin-right:auto;display:block;margin-top:15%;margin-bottom:0%" /> 139 url = re.search('onclick="location.href=\'(.*?)\'', html).group(1) 140 # print "url", url 141 142 html = self.net.http_GET(url, headers).content 143 144 js_data = re.findall('(eval\(function.*?)</script>', html.replace('\n', '')) 145 146 for i in js_data: 147 try: html += jsunpack.unpack(i) 148 except: pass 149 150 # print "html", html 151 print re.search("{src: '([^'].*)',type:", html).group(1) 152 153 return 154 155 resp = self.net.http_GET(url) 156 html = resp.content 157 158 if re.search('>Security Check<', html): 159 print 'errormsg=Too many views per minute. We think you are a spider, crawler, ddoser or something' 160 return 161 162 #<Center> 163 #<b><font color="red">Security Check</font></b><br><br> 164 #<br><br> 165 #Too many views per minute. We think you are a spider, crawler, ddoser or something else.<br> 166 #If you are human, please contact <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="fd9c9f888e9889989c90bd9b919c8e95a5d3898b">[email protected]</a> and <b>whitelist</b> your IP (91.137.28.121).<br> 167 #Or try it again a little bit later. 168 #<br><br> 169 #<center> 170 #<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> 171 #</center> 172 173 # print "# 1 start ##########################" 174 # print html 175 # print "# 1 end ##########################" 176 177 # return 178 cfdcookie = resp._response.info()['set-cookie'] 179 cfduid = re.search('cfduid=(.*?);', cfdcookie).group(1) 180 file_id = re.search("'file_id', '(.*?)'", html).group(1) 181 aff = re.search("'aff', '(.*?)'", html).group(1) 182 headers = {'User-Agent': common.IE_USER_AGENT, 183 'Referer': url, 184 'Cookie': '__cfduid=' + cfduid + '; lang=1'} 185 186 # surl = re.search('src="(.*?' + file_id + ')', html, re.IGNORECASE).group(1) 187 # dummy = self.net.http_GET(url=surl, headers=headers).content 188 headers = {'User-Agent': common.IE_USER_AGENT, 189 'Referer': url, 190 'Cookie': '__cfduid=' + cfduid + '; lang=1; file_id=' + file_id + '; aff=' + aff} 191 html = self.net.http_GET(url=url, headers=headers).content 192 193 fname = re.search('name="fname" value="(.*?)"', html).group(1) 194 hash = re.search('name="hash" value="(.*?)"', html).group(1) 195 id = re.search('name="id" value="(.*?)"', html).group(1) 196 action = re.search('method="POST" action="(.*?)"', html).group(1) 197 fdata = {'op': 'download1', 198 'usr_login': '', 199 'id': id, 200 'fname': fname, 201 'referer': '', 202 'hash': hash} 203 # 'imhuman': 'Proceed to video' 204 # furl = 'http://www.flashx.tv/dl'# + media_id 205 206 sleeptime = re.search('>([0-9])</span> seconds<', html).group(1) 207 # print "action: ", action 208 # print "fdata: ", fdata 209 # print "headers: ", headers 210 211 # print "sleeptime", sleeptime 212 213 self.__getJS(html, headers) 214 215 time.sleep(8) 216 html = self.net.http_POST(url=action, form_data=fdata, headers=headers).content 217 # print "# 2 start ##########################" 218 # print html 219 # print "# 2 end ##########################" 220 21 221 js_data = re.findall('(eval\(function.*?)</script>', html.replace('\n', '')) 22 222 # print "# 3 start ##########################" 223 # print js_data 224 # print "# 3 end ##########################" 225 23 226 for i in js_data: 24 227 try: html += jsunpack.unpack(i) 25 228 except: pass 26 print "html", html 27 229 230 # print "# 3 start ##########################" 231 # print html 232 # print "# 3 end ##########################" 233 234 # <center><font size="4">You try to access the video with Kodi / XBMC / TV BOX or AdBlock.<br><br> 235 # <font color="red">This is prohibited!</font></font><br><br><br> 236 # <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> 237 # Or disable your <b>adblock addon</b> and try again.<br><br> 238 # 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> 239 # <br><br> 240 241 if re.search('>You try to access the video with Kodi / XBMC / TV BOX or AdBlock.<', html): 242 print 'errormsg=You try to access the video with Kodi / XBMC / TV BOX or AdBlock.' 243 return 244 245 246 #{src: 'https://flashx1.tv/cdn107/5k7x22t6vivfjuw5lwxyzw2fsdqgparrhy55dd75c464tmacqfoh7ooeg7mq/normal.mp4',type: 'video/mp4',label: 'SD',res: 360}, 247 248 print re.search("{src: '([^'].*)',type:", html).group(1) 249 28 250 sys.stdout = FlashxResolver() -
titan/mediathek/localhoster/hoster.sh
r44495 r44496 156 156 flashx() 157 157 { 158 TMPURL=$(echo $INPUT | sed "s!\.tv/!\.tv/embed-!") 159 $curlbin "$TMPURL" -o $TMP/cache.$FILENAME.1 160 TMPURL=`cat $TMP/cache.$FILENAME.1 | sed -nr "s/.*location.href='([^']+)'.*/\1/p" ` 161 $BIN $CMD/flashx.py $TMPURL > $TMP/cache.$FILENAME.2 162 # cat $TMP/cache.$FILENAME.2 | grep "video/mp4" | sed -nr "s/.*src:\\\'([^']+)\\\'.*/\1/p" 163 164 STREAMLIST="$TMP/$TYPE.$hoster.$FILENAME.streamlist" 165 cat $TMP/cache.$FILENAME.2 | grep "video/mp4" | sed -nr "s/.*src:\\\'([^']+)\\\'.*/\1/p" > $STREAMLIST 158 # $BIN $CMD/flashx.py $INPUT 159 #exit 160 $BIN $CMD/flashx.py $INPUT > $TMP/cache.$FILENAME.2 161 STREAMLIST="$TMP/$TYPE.$hoster.$FILENAME.streamlist" 162 cat $TMP/cache.$FILENAME.2 > $STREAMLIST 163 # cat $TMP/cache.$FILENAME.2 | grep "video/mp4" | sed -nr "s/.*src:\\\'([^']+)\\\'.*/\1/p" > $STREAMLIST 166 164 echo $STREAMLIST 167 165 }
Note: See TracChangeset
for help on using the changeset viewer.