Enigma2 plugin to to play various online streams (mostly Latvian).

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197
  1. # -*- coding: utf-8 -*-
  2. # Based on (root)/trunk/xbmc-addons/src/plugin.video.polishtv.live/hosts/ @ 419 - Wersja 636
  3. ###################################################
  4. # LOCAL import
  5. ###################################################
  6. from pCommon import common, CParsingHelper
  7. from Plugins.Extensions.IPTVPlayer.components.iptvplayerinit import SetIPTVPlayerLastHostError
  8. from Plugins.Extensions.IPTVPlayer.tools.iptvtypes import strwithmeta
  9. from Plugins.Extensions.IPTVPlayer.tools.iptvtools import printDBG, printExc, CSelOneLink, GetCookieDir, byteify, formatBytes, GetPyScriptCmd
  10. from Plugins.Extensions.IPTVPlayer.libs.crypto.hash.md5Hash import MD5
  11. from Plugins.Extensions.IPTVPlayer.libs.gledajfilmDecrypter import gledajfilmDecrypter
  12. from Plugins.Extensions.IPTVPlayer.libs.crypto.cipher.aes import AES
  13. from Plugins.Extensions.IPTVPlayer.libs.crypto.cipher.aes_cbc import AES_CBC
  14. from Plugins.Extensions.IPTVPlayer.libs.crypto.cipher.base import noPadding
  15. from Plugins.Extensions.IPTVPlayer.libs.youtube_dl.utils import unescapeHTML, clean_html, _unquote
  16. from Plugins.Extensions.IPTVPlayer.libs.urlparserhelper import unpackJSPlayerParams, unpackJS, \
  17. getParamsTouple, JS_FromCharCode, \
  18. JS_toString, \
  19. VIDUPME_decryptPlayerParams, \
  20. VIDEOWEED_unpackJSPlayerParams, \
  21. SAWLIVETV_decryptPlayerParams, \
  22. VIDEOMEGA_decryptPlayerParams, \
  23. OPENLOADIO_decryptPlayerParams, \
  24. TEAMCASTPL_decryptPlayerParams, \
  25. VIDEOWEED_decryptPlayerParams, \
  26. captchaParser, \
  27. getDirectM3U8Playlist, \
  28. decorateUrl, \
  29. getF4MLinksWithMeta, \
  30. MYOBFUSCATECOM_OIO, \
  31. MYOBFUSCATECOM_0ll, \
  32. int2base, drdX_fx, \
  33. unicode_escape, JS_FromCharCode, pythonUnescape
  34. from Plugins.Extensions.IPTVPlayer.libs.aadecoder import AADecoder
  35. from Plugins.Extensions.IPTVPlayer.iptvdm.iptvdh import DMHelper
  36. from Plugins.Extensions.IPTVPlayer.components.asynccall import iptv_execute
  37. ###################################################
  38. # FOREIGN import
  39. ###################################################
  40. import re
  41. import time
  42. import urllib
  43. import socket
  44. import string
  45. import base64
  46. import math
  47. from xml.etree import cElementTree
  48. from random import random, randint, randrange
  49. from urlparse import urlparse, parse_qs
  50. from binascii import hexlify, unhexlify, a2b_hex
  51. from hashlib import md5, sha256
  52. from Tools.Directories import resolveFilename, SCOPE_PLUGINS
  53. from Components.config import config
  54. try: import json
  55. except: import simplejson as json
  56. import codecs
  57. from Plugins.Extensions.IPTVPlayer.libs.youtube_dl.extractor.youtube import YoutubeIE
  58. from Plugins.Extensions.IPTVPlayer.libs.youtube_dl.extractor.mtv import GametrailersIE
  59. try: from urlparse import urlsplit, urlunsplit
  60. except: printExc()
  61. ###################################################
  62. class urlparser:
  63. def __init__(self):
  64. self.cm = common()
  65. self.pp = pageParser()
  66. self.setHostsMap()
  67. @staticmethod
  68. def decorateUrl(url, metaParams={}):
  69. return decorateUrl(url, metaParams)
  70. @staticmethod
  71. def decorateParamsFromUrl(baseUrl, overwrite=False):
  72. printDBG("urlparser.decorateParamsFromUrl >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + baseUrl)
  73. tmp = baseUrl.split('|')
  74. baseUrl = urlparser.decorateUrl(tmp[0].strip(), strwithmeta(baseUrl).meta)
  75. KEYS_TAB = list(DMHelper.HANDLED_HTTP_HEADER_PARAMS)
  76. KEYS_TAB.extend(["iptv_audio_url", "Host", "Accept"])
  77. if 2 == len(tmp):
  78. baseParams = tmp[1].strip()
  79. try:
  80. params = parse_qs(baseParams)
  81. for key in params.keys():
  82. if key not in KEYS_TAB: continue
  83. if not overwrite and key in baseUrl.meta: continue
  84. try: baseUrl.meta[key] = params[key][0]
  85. except: printExc()
  86. except: printExc()
  87. return baseUrl
  88. def preparHostForSelect(self, v, resolveLink = False):
  89. valTab = []
  90. i = 0
  91. if len(v) > 0:
  92. for url in (v.values() if type(v) is dict else v):
  93. if 1 == self.checkHostSupport(url):
  94. hostName = self.getHostName(url, True)
  95. i=i+1
  96. if resolveLink:
  97. url = self.getVideoLink( url )
  98. if isinstance(url, basestring) and url.startswith('http'):
  99. valTab.append({'name': (str(i) + '. ' + hostName), 'url': url})
  100. return valTab
  101. def getItemTitles(self, table):
  102. out = []
  103. for i in range(len(table)):
  104. value = table[i]
  105. out.append(value[0])
  106. return out
  107. #anyfiles, bestreams, cda, cloudyvideos, flashx, neodrive, novamov, nowvideo, openload, played, realvid, streamin, streamplay, thevideo, video, videomega, videowood, vidgg, vidspot,
  108. #vidto, vidup, vidzer, vodlocker, vshare, vshareio, yourvideohost, youtube, youwatch
  109. # neodrive
  110. def setHostsMap(self):
  111. self.hostMap = {
  112. 'putlocker.com': self.pp.parserFIREDRIVE ,
  113. 'firedrive.com': self.pp.parserFIREDRIVE ,
  114. 'sockshare.com': self.pp.parserSOCKSHARE ,
  115. 'megustavid.com': self.pp.parserMEGUSTAVID ,
  116. #'hd3d.cc': self.pp.parserHD3D ,
  117. 'sprocked.com': self.pp.parserSPROCKED ,
  118. 'wgrane.pl': self.pp.parserWGRANE ,
  119. 'cda.pl': self.pp.parserCDA ,
  120. 'ebd.cda.pl': self.pp.parserCDA ,
  121. 'video.anyfiles.pl': self.pp.parserANYFILES ,
  122. 'videoweed.es': self.pp.parserVIDEOWEED ,
  123. 'videoweed.com': self.pp.parserVIDEOWEED ,
  124. 'bitvid.sx': self.pp.parserVIDEOWEED ,
  125. 'novamov.com': self.pp.parserNOVAMOV ,
  126. 'nowvideo.eu': self.pp.parserNOWVIDEO ,
  127. 'nowvideo.sx': self.pp.parserNOWVIDEO ,
  128. 'rapidvideo.com': self.pp.parserRAPIDVIDEO ,
  129. 'videoslasher.com': self.pp.parserVIDEOSLASHER ,
  130. 'dailymotion.com': self.pp.parserDAILYMOTION ,
  131. 'video.sibnet.ru': self.pp.parserSIBNET ,
  132. 'vk.com': self.pp.parserVK ,
  133. 'anime-shinden.info': self.pp.parserANIMESHINDEN ,
  134. 'content.peteava.ro': self.pp.parserPETEAVA ,
  135. 'i.vplay.ro': self.pp.parserVPLAY ,
  136. 'nonlimit.pl': self.pp.parserIITV ,
  137. 'streamo.tv': self.pp.parserIITV ,
  138. 'divxstage.eu': self.pp.parserDIVXSTAGE ,
  139. 'divxstage.to': self.pp.parserDIVXSTAGE ,
  140. 'movdivx.com': self.pp.parserMODIVXCOM ,
  141. 'movshare.net': self.pp.parserWHOLECLOUD ,
  142. 'wholecloud.net': self.pp.parserWHOLECLOUD ,
  143. 'tubecloud.net': self.pp.parserTUBECLOUD ,
  144. 'bestreams.net': self.pp.parserBESTREAMS ,
  145. 'freedisc.pl': self.pp.parserFREEDISC ,
  146. 'dwn.so': self.pp.parserDWN ,
  147. 'st.dwn.so': self.pp.parserDWN ,
  148. 'ginbig.com': self.pp.parserGINBIG ,
  149. 'qfer.net': self.pp.parserQFER ,
  150. 'streamcloud.eu': self.pp.parserSTREAMCLOUD ,
  151. 'limevideo.net': self.pp.parserLIMEVIDEO ,
  152. 'donevideo.com': self.pp.parserLIMEVIDEO ,
  153. 'scs.pl': self.pp.parserSCS ,
  154. 'youwatch.org': self.pp.parserYOUWATCH ,
  155. 'played.to': self.pp.parserPLAYEDTO ,
  156. 'videomega.tv': self.pp.parserVIDEOMEGA ,
  157. 'up2stream.com': self.pp.parserVIDEOMEGA ,
  158. 'vidto.me': self.pp.parserVIDTO ,
  159. 'vidstream.in': self.pp.parserVIDSTREAM ,
  160. 'faststream.in': self.pp.parserVIDSTREAM ,
  161. 'video.rutube.ru': self.pp.parserRUTUBE ,
  162. 'rutube.ru': self.pp.parserRUTUBE ,
  163. 'youtube.com': self.pp.parserYOUTUBE ,
  164. 'youtu.be': self.pp.parserYOUTUBE ,
  165. 'google.com': self.pp.parserGOOGLE ,
  166. 'tinymov.net': self.pp.parserTINYMOV ,
  167. 'topupload.tv': self.pp.parserTOPUPLOAD ,
  168. 'maxupload.tv': self.pp.parserTOPUPLOAD ,
  169. 'video.yandex.ru': self.pp.parserYANDEX ,
  170. 'seositer.com': self.pp.parserYANDEX ,
  171. 'liveleak.com': self.pp.parserLIVELEAK ,
  172. 'vidup.me': self.pp.parserVIDUPME ,
  173. 'embed.trilulilu.ro': self.pp.parserTRILULILU ,
  174. 'videa.hu': self.pp.parserVIDEA ,
  175. 'emb.aliez.tv': self.pp.parserALIEZ ,
  176. 'my.mail.ru': self.pp.parserVIDEOMAIL ,
  177. 'api.video.mail.ru': self.pp.parserVIDEOMAIL ,
  178. 'videoapi.my.mail.ru': self.pp.parserVIDEOMAIL ,
  179. 'wrzuta.pl': self.pp.parserWRZUTA ,
  180. 'goldvod.tv': self.pp.parserGOLDVODTV ,
  181. 'vidzer.net': self.pp.parserVIDZER ,
  182. 'nowvideo.ch': self.pp.parserNOWVIDEOCH ,
  183. 'streamin.to': self.pp.parserSTREAMINTO ,
  184. 'vidsso.com': self.pp.parserVIDSSO ,
  185. 'wat.tv': self.pp.parseWATTV ,
  186. 'tune.pk': self.pp.parseTUNEPK ,
  187. 'netu.tv': self.pp.parseNETUTV ,
  188. 'hqq.tv': self.pp.parseNETUTV ,
  189. 'waaw.tv': self.pp.parseNETUTV ,
  190. 'vshare.io': self.pp.parseVSHAREIO ,
  191. 'vidspot.net': self.pp.parserVIDSPOT ,
  192. 'video.tt': self.pp.parserVIDEOTT ,
  193. 'vodlocker.com': self.pp.parserVODLOCKER ,
  194. 'vshare.eu': self.pp.parserVSHAREEU ,
  195. 'vidbull.com': self.pp.parserVIDBULL ,
  196. 'divxpress.com': self.pp.parserDIVEXPRESS ,
  197. 'promptfile.com': self.pp.parserPROMPTFILE ,
  198. 'playreplay.net': self.pp.parserPLAYEREPLAY ,
  199. 'moevideo.net': self.pp.parserPLAYEREPLAY ,
  200. 'videowood.tv': self.pp.parserVIDEOWOODTV ,
  201. 'movreel.com': self.pp.parserMOVRELLCOM ,
  202. 'vidfile.net': self.pp.parserVIDFILENET ,
  203. 'mp4upload.com': self.pp.parserMP4UPLOAD ,
  204. 'yukons.net': self.pp.parserYUKONS ,
  205. 'ustream.tv': self.pp.parserUSTREAMTV ,
  206. 'privatestream.tv': self.pp.parserPRIVATESTREAM ,
  207. 'abcast.biz': self.pp.parserABCASTBIZ ,
  208. 'abcast.net': self.pp.parserABCASTBIZ ,
  209. 'goodcast.co': self.pp.parserGOODCASTCO ,
  210. 'myvi.ru': self.pp.parserMYVIRU ,
  211. 'myvi.tv': self.pp.parserMYVIRU ,
  212. 'archive.org': self.pp.parserARCHIVEORG ,
  213. 'sawlive.tv': self.pp.parserSAWLIVETV ,
  214. 'shidurlive.com': self.pp.parserSHIDURLIVECOM ,
  215. 'castalba.tv': self.pp.parserCASTALBATV ,
  216. 'fxstream.biz': self.pp.parserFXSTREAMBIZ ,
  217. 'webcamera.pl': self.pp.parserWEBCAMERAPL ,
  218. 'flashx.tv': self.pp.parserFLASHXTV ,
  219. 'flashx.pw': self.pp.parserFLASHXTV ,
  220. 'myvideo.de': self.pp.parserMYVIDEODE ,
  221. 'vidzi.tv': self.pp.parserVIDZITV ,
  222. 'tvp.pl': self.pp.parserTVP ,
  223. 'junkyvideo.com': self.pp.parserJUNKYVIDEO ,
  224. 'live.bvbtotal.de': self.pp.parserLIVEBVBTOTALDE,
  225. 'partners.nettvplus.com': self.pp.parserNETTVPLUSCOM,
  226. '7cast.net': self.pp.parser7CASTNET ,
  227. 'facebook.com': self.pp.parserFACEBOOK ,
  228. 'cloudyvideos.com': self.pp.parserCLOUDYVIDEOS ,
  229. 'thevideo.me': self.pp.parserTHEVIDEOME ,
  230. 'xage.pl': self.pp.parserXAGEPL ,
  231. 'castamp.com': self.pp.parserCASTAMPCOM ,
  232. 'crichd.tv': self.pp.parserCRICHDTV ,
  233. 'castto.me': self.pp.parserCASTTOME ,
  234. 'cast4u.tv': self.pp.parserCAST4UTV ,
  235. 'hdcast.info': self.pp.parserHDCASTINFO ,
  236. 'deltatv.pw': self.pp.parserDELTATVPW ,
  237. 'pxstream.tv': self.pp.parserPXSTREAMTV ,
  238. 'coolcast.eu': self.pp.parserCOOLCASTEU ,
  239. 'filenuke.com': self.pp.parserFILENUKE ,
  240. 'sharesix.com': self.pp.parserFILENUKE ,
  241. 'thefile.me': self.pp.parserTHEFILEME ,
  242. 'cloudtime.to': self.pp.parserCLOUDTIME ,
  243. 'nosvideo.com': self.pp.parserNOSVIDEO ,
  244. 'letwatch.us': self.pp.parserLETWATCHUS ,
  245. 'uploadc.com': self.pp.parserUPLOADCCOM ,
  246. 'mightyupload.com': self.pp.parserMIGHTYUPLOAD ,
  247. 'zalaa.com': self.pp.parserZALAACOM ,
  248. 'allmyvideos.net': self.pp.parserALLMYVIDEOS ,
  249. 'streamplay.cc': self.pp.parserSTREAMPLAYCC ,
  250. 'yourvideohost.com': self.pp.parserYOURVIDEOHOST ,
  251. 'vidgg.to': self.pp.parserVIDGGTO ,
  252. 'vid.gg': self.pp.parserVIDGGTO ,
  253. 'tiny.cc': self.pp.parserTINYCC ,
  254. 'picasaweb.google.com': self.pp.parserPICASAWEB ,
  255. 'stream4k.to': self.pp.parserSTREAM4KTO ,
  256. 'onet.pl': self.pp.parserONETTV ,
  257. 'onet.tv': self.pp.parserONETTV ,
  258. 'swirownia.com.usrfiles.com': self.pp.parserSWIROWNIA,
  259. 'byetv.org': self.pp.paserBYETVORG ,
  260. 'putlive.in': self.pp.paserPUTLIVEIN ,
  261. 'liveall.tv': self.pp.paserLIVEALLTV ,
  262. 'p2pcast.tv': self.pp.paserP2PCASTTV ,
  263. 'streamlive.to': self.pp.paserSTREAMLIVETO ,
  264. 'megom.tv': self.pp.paserMEGOMTV ,
  265. 'openload.io': self.pp.parserOPENLOADIO ,
  266. 'openload.co': self.pp.parserOPENLOADIO ,
  267. 'gametrailers.com': self.pp.parserGAMETRAILERS ,
  268. 'vevo.com': self.pp.parserVEVO ,
  269. 'shared.sx': self.pp.parserSHAREDSX ,
  270. 'gorillavid.in': self.pp.parserFASTVIDEOIN ,
  271. 'daclips.in': self.pp.parserFASTVIDEOIN ,
  272. 'movpod.in': self.pp.parserFASTVIDEOIN ,
  273. 'fastvideo.in': self.pp.parserFASTVIDEOIN ,
  274. 'realvid.net': self.pp.parserFASTVIDEOIN ,
  275. 'rapidvideo.ws': self.pp.parserRAPIDVIDEOWS ,
  276. 'hdvid.tv': self.pp.parserHDVIDTV ,
  277. 'exashare.com': self.pp.parserEXASHARECOM ,
  278. 'bojem3a.info': self.pp.parserEXASHARECOM ,
  279. 'openload.info': self.pp.parserEXASHARECOM ,
  280. 'chefti.info': self.pp.parserEXASHARECOM ,
  281. 'allvid.ch': self.pp.parserALLVIDCH ,
  282. 'posiedze.pl': self.pp.parserPOSIEDZEPL ,
  283. 'neodrive.co': self.pp.parserNEODRIVECO ,
  284. 'cloudy.ec': self.pp.parserCLOUDYEC ,
  285. 'ideoraj.ch': self.pp.parserCLOUDYEC ,
  286. 'miplayer.net': self.pp.parserMIPLAYERNET ,
  287. 'yocast.tv': self.pp.parserYOCASTTV ,
  288. 'liveonlinetv247.info': self.pp.parserLIVEONLINE247 ,
  289. 'liveonlinetv247.net': self.pp.parserLIVEONLINE247 ,
  290. 'filepup.net': self.pp.parserFILEPUPNET ,
  291. 'superfilm.pl': self.pp.parserSUPERFILMPL ,
  292. 'sendvid.com': self.pp.parserSENDVIDCOM ,
  293. 'filehoot.com': self.pp.parserFILEHOOT ,
  294. 'ssh101.com': self.pp.parserSSH101COM ,
  295. 'twitch.tv': self.pp.parserTWITCHTV ,
  296. 'sostart.org': self.pp.parserSOSTARTORG ,
  297. 'sostart.pw': self.pp.parserSOSTARTPW ,
  298. 'theactionlive.com': self.pp.parserTHEACTIONLIVE ,
  299. 'biggestplayer.me': self.pp.parserBIGGESTPLAYER ,
  300. 'goodrtmp.com': self.pp.parserGOODRTMP ,
  301. 'life-rtmp.com': self.pp.parserLIFERTMP ,
  302. 'openlive.org': self.pp.parserOPENLIVEORG ,
  303. 'moonwalk.cc': self.pp.parserMOONWALKCC ,
  304. 'serpens.nl': self.pp.parserMOONWALKCC ,
  305. '37.220.36.15': self.pp.parserMOONWALKCC ,
  306. 'easyvid.org': self.pp.parserEASYVIDORG ,
  307. 'playvid.org': self.pp.parserEASYVIDORG ,
  308. 'mystream.la': self.pp.parserMYSTREAMLA ,
  309. 'ok.ru': self.pp.parserOKRU ,
  310. 'putstream.com': self.pp.parserPUTSTREAM ,
  311. 'live-stream.tv': self.pp.parserLIVESTRAMTV ,
  312. 'zerocast.tv': self.pp.parserZEROCASTTV ,
  313. 'vid.ag': self.pp.parserVIDAG ,
  314. 'albfilm.com': self.pp.parserALBFILMCOM ,
  315. 'hdfilmstreaming.com': self.pp.parserHDFILMSTREAMING,
  316. 'allocine.fr': self.pp.parserALLOCINEFR ,
  317. 'video.meta.ua': self.pp.parseMETAUA ,
  318. 'xvidstage.com': self.pp.parseXVIDSTAGECOM ,
  319. 'speedvideo.net': self.pp.parseSPEEDVICEONET ,
  320. 'vid.me': self.pp.parseVIDME ,
  321. 'veehd.com': self.pp.parseVEEHDCOM ,
  322. 'sharerepo.com': self.pp.parseSHAREREPOCOM ,
  323. 'easyvideo.me': self.pp.parseEASYVIDEOME ,
  324. 'playbb.me': self.pp.parseEASYVIDEOME ,
  325. 'uptostream.com': self.pp.parseUPTOSTREAMCOM ,
  326. 'vimeo.com': self.pp.parseVIMEOCOM ,
  327. 'jacvideo.com': self.pp.parseJACVIDEOCOM ,
  328. 'caston.tv': self.pp.parseCASTONTV ,
  329. 'bro.adca.st': self.pp.parseBROADCAST ,
  330. 'bro.adcast.tech': self.pp.parseBROADCAST ,
  331. 'moshahda.net': self.pp.parseMOSHAHDANET ,
  332. 'stream.moe': self.pp.parseSTREAMMOE ,
  333. 'publicvideohost.org': self.pp.parsePUBLICVIDEOHOST,
  334. 'castflash.pw': self.pp.parseCASTFLASHPW ,
  335. 'flashlive.pw': self.pp.parseCASTFLASHPW ,
  336. 'castasap.pw': self.pp.parseCASTFLASHPW ,
  337. 'fastflash.pw': self.pp.parseCASTFLASHPW ,
  338. #'billionuploads.com': self.pp.parserBILLIONUPLOADS ,
  339. }
  340. return
  341. def getHostName(self, url, nameOnly = False):
  342. hostName = ''
  343. match = re.search('https?://(?:www.)?(.+?)/', url)
  344. if match:
  345. hostName = match.group(1)
  346. if (nameOnly):
  347. n = hostName.split('.')
  348. hostName = n[-2]
  349. hostName = hostName.lower()
  350. printDBG("_________________getHostName: [%s] -> [%s]" % (url, hostName))
  351. return hostName
  352. def getParser(self, url, host=None):
  353. if None == host:
  354. host = self.getHostName(url)
  355. parser = self.hostMap.get(host, None)
  356. if None == parser:
  357. host2 = host[host.find('.')+1:]
  358. printDBG('urlparser.getParser II try host[%s]->host2[%s]' % (host, host2))
  359. parser = self.hostMap.get(host2, None)
  360. return parser
  361. def checkHostSupport(self, url):
  362. # -1 - not supported
  363. # 0 - unknown
  364. # 1 - supported
  365. host = self.getHostName(url)
  366. # quick fix
  367. if host == 'facebook.com' and 'likebox.php' in url:
  368. return 0
  369. ret = 0
  370. parser = self.getParser(url, host)
  371. if None != parser:
  372. return 1
  373. return ret
  374. def getVideoLinkExt(self, url):
  375. videoTab = []
  376. try:
  377. ret = self.getVideoLink(url, True)
  378. if isinstance(ret, basestring):
  379. if 0 < len(ret):
  380. host = self.getHostName(url)
  381. videoTab.append({'name': host, 'url': ret})
  382. elif isinstance(ret, list) or isinstance(ret, tuple):
  383. return ret
  384. except:
  385. printExc()
  386. return videoTab
  387. def getVideoLink(self, url, acceptsList = False):
  388. try:
  389. url = self.decorateParamsFromUrl(url)
  390. nUrl=''
  391. parser = self.getParser(url)
  392. if None != parser:
  393. nUrl = parser(url)
  394. if isinstance(nUrl, list) or isinstance(nUrl, tuple):
  395. if True == acceptsList:
  396. return nUrl
  397. else:
  398. if len(nUrl) > 0:
  399. return nUrl[0]['url']
  400. else:
  401. return False
  402. return nUrl
  403. except:
  404. printExc()
  405. return False
  406. def getAutoDetectedStreamLink(self, baseUrl, data=None):
  407. printDBG("urlparser.getAutoDetectedStreamLink baseUrl[%s]" % baseUrl)
  408. url = baseUrl
  409. num = 0
  410. while True:
  411. num += 1
  412. if None == data:
  413. url = strwithmeta(url)
  414. HTTP_HEADER = dict(pageParser.HTTP_HEADER)
  415. HTTP_HEADER['Referer'] = url.meta.get('Referer', url)
  416. sts, data = self.cm.getPage(url, {'header' : HTTP_HEADER})
  417. if not sts: return []
  418. data = re.sub("<!--[\s\S]*?-->", "", data)
  419. if 1 == num and 'http://up4free.com/' in data:
  420. id = self.cm.ph.getSearchGroups(data, """id=['"]([^'^"]+?)['"];""")[0]
  421. tmpUrl = url
  422. url = 'http://embed.up4free.com/stream.php?id=' + id + '&amp;width=700&amp;height=450&amp;stretching='
  423. url = strwithmeta(url, {'Referer':tmpUrl})
  424. data = None
  425. continue
  426. elif 'caston.tv/player.php' in data:
  427. id = self.cm.ph.getSearchGroups(data, """var\sid\s?=[^0-9]([0-9]+?)[^0-9]""")[0]
  428. if id == '': id = self.cm.ph.getSearchGroups(data, """id\s?=[^0-9]([0-9]+?)[^0-9]""")[0]
  429. videoUrl = 'http://www.caston.tv/player.php?width=1920&height=419&id={0}'.format(id)
  430. videoUrl = strwithmeta(videoUrl, {'Referer':strwithmeta(baseUrl).meta.get('Referer', baseUrl)})
  431. return self.getVideoLinkExt(videoUrl)
  432. elif 'liveonlinetv247' in data:
  433. videoUrl = self.cm.ph.getSearchGroups(data, """['"](http://[^'^"]*?liveonlinetv247[^'^"]+?)['"]""")[0]
  434. videoUrl = strwithmeta(videoUrl, {'Referer':strwithmeta(baseUrl).meta.get('Referer', baseUrl)})
  435. return self.getVideoLinkExt(videoUrl)
  436. elif 'ssh101.com/secure/' in data:
  437. videoUrl = self.cm.ph.getSearchGroups(data, """['"]([^'^"]*?ssh101.com/secure/[^'^"]+?)['"]""")[0]
  438. videoUrl = strwithmeta(videoUrl, {'Referer':strwithmeta(baseUrl).meta.get('Referer', baseUrl)})
  439. return self.getVideoLinkExt(videoUrl)
  440. elif 'twitch.tv' in data:
  441. videoUrl = self.cm.ph.getSearchGroups(data, """['"]([^'^"]*?twitch.tv[^'^"]+?)['"]""")[0]
  442. videoUrl = strwithmeta(videoUrl, {'Referer':strwithmeta(baseUrl).meta.get('Referer', baseUrl)})
  443. return self.getVideoLinkExt(videoUrl)
  444. elif 'goodrtmp.com' in data:
  445. videoUrl = self.cm.ph.getSearchGroups(data, """['"]([^'^"]*?goodrtmp.com[^'^"]+?)['"]""")[0]
  446. videoUrl = strwithmeta(videoUrl, {'Referer':strwithmeta(baseUrl).meta.get('Referer', baseUrl)})
  447. return self.getVideoLinkExt(videoUrl)
  448. elif 'life-rtmp.com' in data:
  449. videoUrl = self.cm.ph.getSearchGroups(data, """['"]([^'^"]*?life-rtmp.com[^'^"]+?)['"]""")[0]
  450. videoUrl = strwithmeta(videoUrl, {'Referer':strwithmeta(baseUrl).meta.get('Referer', baseUrl)})
  451. return self.getVideoLinkExt(videoUrl)
  452. elif 'sostart.org' in data:
  453. id = self.cm.ph.getSearchGroups(data, """id=['"]([^'"]+?)['"]""")[0]
  454. videoUrl = 'http://sostart.org/streamk.php?id={0}&width=640&height=390'.format(id)
  455. videoUrl = strwithmeta(videoUrl, {'Referer':strwithmeta(baseUrl).meta.get('Referer', baseUrl)})
  456. return self.getVideoLinkExt(videoUrl)
  457. elif 'bro.adca.' in data:
  458. videoUrl = self.cm.ph.getSearchGroups(data, """['"](http[^'^"]+?bro\.adca\.[^'^"]+?stream\.php\?id=[^'^"]+?)['"]""")[0]
  459. if videoUrl == '':
  460. tmpUrl = self.cm.ph.getSearchGroups(data, """['"](http[^'^"]+?bro\.adca\.[^'^"]+?)['"]""")[0]
  461. if '' == tmpUrl: tmpUrl = self.cm.ph.getSearchGroups(data, """['"](http[^'^"]+?bro\.adcast\.[^'^"]+?)['"]""")[0]
  462. id = self.cm.ph.getSearchGroups(data, """id=['"]([^'"]+?)['"]""")[0]
  463. videoUrl = self.cm.getBaseUrl(tmpUrl) + 'stream.php?id={0}&width=600&height=400'.format(id)
  464. videoUrl = strwithmeta(videoUrl, {'Referer':strwithmeta(baseUrl).meta.get('Referer', baseUrl)})
  465. return self.getVideoLinkExt(videoUrl)
  466. elif 'sostart.pw' in data:
  467. fid = self.cm.ph.getSearchGroups(data, """fid=['"]([0-9]+?)['"]""")[0]
  468. videoUrl = 'http://www.sostart.pw/jwplayer6.php?channel={0}&vw=710&vh=460'.format(fid)
  469. videoUrl = strwithmeta(videoUrl, {'Referer':baseUrl})
  470. return self.getVideoLinkExt(videoUrl)
  471. elif 'theactionlive.com' in data:
  472. id = self.cm.ph.getSearchGroups(data, """id=['"]([^'"]+?)['"]""")[0]
  473. videoUrl = 'http://theactionlive.com/livegamecr2.php?id={0}&width=640&height=460&stretching='.format(id)
  474. videoUrl = strwithmeta(videoUrl, {'Referer':strwithmeta(baseUrl).meta.get('Referer', baseUrl)})
  475. return self.getVideoLinkExt(videoUrl)
  476. elif 'biggestplayer.me' in data:
  477. id = self.cm.ph.getSearchGroups(data, """id=['"]([^'"]+?)['"]""")[0]
  478. videoUrl = 'http://biggestplayer.me/streamcrjeje.php?id={0}&width=640&height=460'.format(id)
  479. videoUrl = strwithmeta(videoUrl, {'Referer':strwithmeta(baseUrl).meta.get('Referer', baseUrl)})
  480. return self.getVideoLinkExt(videoUrl)
  481. elif 'yocast.tv' in data:
  482. fid = self.cm.ph.getSearchGroups(data, """fid=['"]([^'"]+?)['"]""")[0]
  483. videoUrl = 'http://www.yocast.tv/embed.php?live={0}&vw=620&vh=490'.format(fid)
  484. videoUrl = strwithmeta(videoUrl, {'Referer':strwithmeta(baseUrl).meta.get('Referer', baseUrl)})
  485. return self.getVideoLinkExt(videoUrl)
  486. elif 'miplayer.net' in data:
  487. videoUrl = self.cm.ph.getSearchGroups(data, """['"](http://miplayer.net[^'^"]+?)['"]""")[0]
  488. videoUrl = strwithmeta(videoUrl, {'Referer':strwithmeta(baseUrl).meta.get('Referer', baseUrl)})
  489. return self.getVideoLinkExt(videoUrl)
  490. elif 'p2pcast' in data:
  491. id = self.cm.ph.getSearchGroups(data, """id=['"]([0-9]+?)['"]""")[0]
  492. videoUrl = 'http://p2pcast.tv/stream.php?id={0}&live=0&p2p=0&stretching=uniform'.format(id)
  493. videoUrl = strwithmeta(videoUrl, {'Referer':baseUrl})
  494. return self.getVideoLinkExt(videoUrl)
  495. elif 'liveall.tv' in data:
  496. videoUrl = self.cm.ph.getSearchGroups(data, 'SRC="([^"]+?liveall.tv[^"]+?)"', 1, True)[0]
  497. videoUrl = strwithmeta(videoUrl, {'Referer':baseUrl})
  498. return self.getVideoLinkExt(videoUrl)
  499. elif 'putlive.in' in data:
  500. videoUrl = self.cm.ph.getSearchGroups(data, '="([^"]*?putlive.in/[^"]+?)"')[0]
  501. videoUrl = strwithmeta(videoUrl, {'Referer':url})
  502. return self.getVideoLinkExt(videoUrl)
  503. elif 'streamlive.to' in data:
  504. videoUrl = self.cm.ph.getSearchGroups(data, '="([^"]*?streamlive.to/[^"]+?)"')[0]
  505. videoUrl = strwithmeta(videoUrl, {'Referer':baseUrl})
  506. return self.getVideoLinkExt(videoUrl)
  507. elif 'megom.tv' in data:
  508. videoUrl = self.cm.ph.getSearchGroups(data, '="([^"]*?megom.tv/[^"]+?)"')[0]
  509. videoUrl = strwithmeta(videoUrl, {'Referer':baseUrl})
  510. return self.getVideoLinkExt(videoUrl)
  511. elif 'byetv.org' in data:
  512. file = self.cm.ph.getSearchGroups(data, "file=([0-9]+?)[^0-9]")[0]
  513. if '' == file: file = self.cm.ph.getSearchGroups(data, "a=([0-9]+?)[^0-9]")[0]
  514. videoUrl = "http://www.byetv.org/embed.php?a={0}&id=&width=710&height=460&autostart=true&strech=".format(file)
  515. videoUrl = strwithmeta(videoUrl, {'Referer':baseUrl})
  516. return self.getVideoLinkExt(videoUrl)
  517. elif 'castto.me' in data:
  518. fid = self.cm.ph.getSearchGroups(data, """fid=['"]([0-9]+?)['"]""")[0]
  519. videoUrl = 'http://static.castto.me/embed.php?channel={0}&vw=710&vh=460'.format(fid)
  520. videoUrl = strwithmeta(videoUrl, {'Referer':baseUrl})
  521. return self.getVideoLinkExt(videoUrl)
  522. elif 'cast4u.tv' in data:
  523. fid = self.cm.ph.getSearchGroups(data, """fid=['"]([^'^"]+?)['"]""")[0]
  524. videoUrl = 'http://www.cast4u.tv/embed.php?live={0}&vw=700&vh=450'.format(fid)
  525. videoUrl = strwithmeta(videoUrl, {'Referer':baseUrl})
  526. return self.getVideoLinkExt(videoUrl)
  527. elif 'hdcast.info' in data:
  528. fid = self.cm.ph.getSearchGroups(data, """fid=['"]([^'^"]+?)['"]""")[0]
  529. videoUrl = 'http://www.hdcast.info/embed.php?live={0}&vw=700&vh=450'.format(fid)
  530. videoUrl = strwithmeta(videoUrl, {'Referer':baseUrl})
  531. return self.getVideoLinkExt(videoUrl)
  532. elif 'deltatv.pw' in data:
  533. id = self.cm.ph.getSearchGroups(data, """id=['"]([0-9]+?)['"];""")[0]
  534. videoUrl = 'http://deltatv.pw/stream.php?id=' + id
  535. videoUrl = strwithmeta(videoUrl, {'Referer':url})
  536. return self.getVideoLinkExt(videoUrl)
  537. elif 'pxstream.tv' in data:
  538. id = self.cm.ph.getSearchGroups(data, """file=['"]([^'^"]+?)['"];""")[0]
  539. videoUrl = 'http://pxstream.tv/embed.php?file=' + id
  540. videoUrl = strwithmeta(videoUrl, {'Referer':url})
  541. return self.getVideoLinkExt(videoUrl)
  542. elif 'coolcast.eu' in data:
  543. id = self.cm.ph.getSearchGroups(data, """file=['"]([^'^"]+?)['"];""")[0]
  544. videoUrl = 'http://coolcast.eu/?name=' + id
  545. videoUrl = strwithmeta(videoUrl, {'Referer':url})
  546. return self.getVideoLinkExt(videoUrl)
  547. elif 'goodcast.co' in data:
  548. id = self.cm.ph.getSearchGroups(data, """id=['"]([0-9]+?)['"];""")[0]
  549. videoUrl = 'http://goodcast.co/stream.php?id=' + id
  550. videoUrl = strwithmeta(videoUrl, {'Referer':url})
  551. return self.getVideoLinkExt(videoUrl)
  552. elif '7cast.net' in data:
  553. videoUrl = self.cm.ph.getSearchGroups(data, """['"](http[^'^"]+?7cast.net[^'^"]+?)['"]""")[0]
  554. videoUrl = strwithmeta(videoUrl, {'Referer':url})
  555. return self.getVideoLinkExt(videoUrl)
  556. elif 'partners.nettvplus.com' in data:
  557. videoUrl = self.cm.ph.getSearchGroups(data, """['"](http://partners.nettvplus.com[^'^"]+?)['"]""")[0]
  558. return self.getVideoLinkExt(videoUrl)
  559. elif "yukons.net" in data:
  560. channel = self.cm.ph.getDataBeetwenMarkers(data, 'channel="', '"', False)[1]
  561. videoUrl = strwithmeta('http://yukons.net/watch/'+channel, {'Referer':url})
  562. return self.getVideoLinkExt(videoUrl)
  563. elif "castamp.com" in data:
  564. channel = self.cm.ph.getDataBeetwenMarkers(data, 'channel="', '"', False)[1]
  565. videoUrl = strwithmeta('http://www.castamp.com/embed.php?c='+channel, {'Referer':url})
  566. return self.getVideoLinkExt(videoUrl)
  567. elif "crichd.tv" in data:
  568. if baseUrl.startswith('http://crichd.tv'):
  569. videoUrl = strwithmeta(baseUrl, {'Referer':baseUrl})
  570. else:
  571. videoUrl = self.cm.ph.getSearchGroups(data, 'src="(http://crichd.tv[^"]+?)"')[0]
  572. videoUrl = strwithmeta(videoUrl, {'Referer':url})
  573. return self.getVideoLinkExt(videoUrl)
  574. elif "privatestream.tv" in data:
  575. videoUrl = self.cm.ph.getSearchGroups(data, '"(http://privatestream.tv/[^"]+?)"')[0]
  576. videoUrl = strwithmeta(videoUrl, {'Referer':url})
  577. return self.getVideoLinkExt(videoUrl)
  578. elif "ustream.tv" in data:
  579. videoUrl = self.cm.ph.getSearchGroups(data, 'src="([^"]+?ustream.tv[^"]+?)"')[0]
  580. if videoUrl.startswith('//'):
  581. videoUrl = 'http:' + videoUrl
  582. videoUrl = strwithmeta(videoUrl, {'Referer':url})
  583. return self.getVideoLinkExt(videoUrl)
  584. elif 'rtmp://' in data:
  585. tmp = self.cm.ph.getSearchGroups(data, """(rtmp://[^'^"]+?)['"]""")[0]
  586. tmp = tmp.split('&amp;')
  587. r = tmp[0]
  588. if 1 < len(tmp)and tmp[1].startswith('c='):
  589. playpath = tmp[1][2:]
  590. else:
  591. playpath = self.cm.ph.getSearchGroups(data, """['"]*url['"]*[ ]*?:[ ]*?['"]([^'^"]+?)['"]""")[0]
  592. if '' != playpath:
  593. r += ' playpath=%s' % playpath.strip()
  594. swfUrl = self.cm.ph.getSearchGroups(data, """['"](http[^'^"]+?swf)['"]""")[0]
  595. r += ' swfUrl=%s pageUrl=%s' % (swfUrl, url)
  596. return [{'name':'team-cast', 'url':r}]
  597. elif 'abcast.biz' in data or 'abcast.net' in data :
  598. file = self.cm.ph.getSearchGroups(data, "file='([^']+?)'")[0]
  599. if '' != file:
  600. if 'abcast.net' in data:
  601. videoUrl = 'http://abcast.net/embed.php?file='
  602. else:
  603. videoUrl = 'http://abcast.biz/embed.php?file='
  604. videoUrl += file+'&width=640&height=480'
  605. videoUrl = strwithmeta(videoUrl, {'Referer':url})
  606. return self.getVideoLinkExt(videoUrl)
  607. elif 'openlive.org' in data:
  608. file = self.cm.ph.getSearchGroups(data, """file=['"]([^'^"]+?)['"];""")[0]
  609. videoUrl = 'http://openlive.org/embed.php?file={0}&width=710&height=460'.format(file)
  610. videoUrl = strwithmeta(videoUrl, {'Referer':url})
  611. return self.getVideoLinkExt(videoUrl)
  612. elif 'shidurlive.com' in data:
  613. videoUrl = self.cm.ph.getSearchGroups(data, """src=['"](http[^'^"]+?shidurlive.com[^'^"]+?)['"]""")[0]
  614. if '' != videoUrl:
  615. videoUrl = strwithmeta(videoUrl, {'Referer':url})
  616. return self.getVideoLinkExt(videoUrl)
  617. elif 'sawlive.tv' in data:
  618. videoUrl = self.cm.ph.getSearchGroups(data, """src=['"](http[^'^"]+?sawlive.tv[^'^"]+?)['"]""")[0]
  619. if '' != videoUrl:
  620. videoUrl = strwithmeta(videoUrl, {'Referer':baseUrl})
  621. return self.getVideoLinkExt(videoUrl)
  622. elif "castalba.tv" in data:
  623. id = self.cm.ph.getSearchGroups(data, """id=['"]([0-9]+?)['"];""")[0]
  624. if '' != id:
  625. videoUrl = 'http://castalba.tv/embed.php?cid='+id+'&wh=640&ht=400&r=team-cast.pl.cp-21.webhostbox.net'
  626. videoUrl = strwithmeta(videoUrl, {'Referer':url})
  627. return self.getVideoLinkExt(videoUrl)
  628. elif "fxstream.biz" in data:
  629. file = self.cm.ph.getSearchGroups(data, """file=['"]([^'^"]+?)['"];""")[0]
  630. if '' != file:
  631. videoUrl = 'http://fxstream.biz/embed.php?file='+file+'&width=640&height=400'
  632. videoUrl = strwithmeta(videoUrl, {'Referer':url})
  633. return self.getVideoLinkExt(videoUrl)
  634. else:
  635. file = self.cm.ph.getSearchGroups(data, """['"]*(http[^'^"]+?\.m3u8[^'^"]*?)['"]""")[0]
  636. if '' != file:
  637. file = file.split('&#038;')[0]
  638. return getDirectM3U8Playlist(urllib.unquote(clean_html(file)), checkExt=False)
  639. if 'x-vlc-plugin' in data:
  640. vlcUrl = self.cm.ph.getSearchGroups(data, """target=['"](http[^'^"]+?)['"]""")[0]
  641. if '' != vlcUrl: return [{'name':'vlc', 'url':vlcUrl}]
  642. printDBG("=======================================================================")
  643. printDBG("No link extractor for url[%s]" % url)
  644. printDBG("=======================================================================")
  645. return []
  646. class pageParser:
  647. HTTP_HEADER= { 'User-Agent' : 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:21.0) Gecko/20100101 Firefox/21.0',
  648. 'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  649. 'Content-type': 'application/x-www-form-urlencoded' }
  650. def __init__(self):
  651. self.cm = common()
  652. self.captcha = captchaParser()
  653. self.ytParser = None
  654. self.moonwalkParser = None
  655. self.vevoIE = None
  656. #config
  657. self.COOKIE_PATH = GetCookieDir('')
  658. #self.hd3d_login = config.plugins.iptvplayer.hd3d_login.value
  659. #self.hd3d_password = config.plugins.iptvplayer.hd3d_password.value
  660. def getYTParser(self):
  661. if self.ytParser == None:
  662. try:
  663. from youtubeparser import YouTubeParser
  664. self.ytParser = YouTubeParser()
  665. except:
  666. printExc()
  667. self.ytParser = None
  668. return self.ytParser
  669. def getVevoIE(self):
  670. if self.vevoIE == None:
  671. try:
  672. from Plugins.Extensions.IPTVPlayer.libs.youtube_dl.extractor.vevo import VevoIE
  673. self.vevoIE = VevoIE()
  674. except:
  675. self.vevoIE = None
  676. printExc()
  677. return self.vevoIE
  678. def getMoonwalkParser(self):
  679. if self.moonwalkParser == None:
  680. try:
  681. from moonwalkcc import MoonwalkParser
  682. self.moonwalkParser = MoonwalkParser()
  683. except:
  684. printExc()
  685. self.moonwalkParser = None
  686. return self.moonwalkParser
  687. def _findLinks(self, data, serverName='', linkMarker=r'''['"]?file['"]?[ ]*:[ ]*['"](http[^"^']+)['"][,}]''', m1='sources', m2=']', contain=''):
  688. linksTab = []
  689. srcData = self.cm.ph.getDataBeetwenMarkers(data, m1, m2, False)[1].split('},')
  690. for item in srcData:
  691. item += '},'
  692. if contain != '' and contain not in item: continue
  693. link = self.cm.ph.getSearchGroups(item, linkMarker)[0].replace('\/', '/')
  694. if '%3A%2F%2F' in link and '://' not in link:
  695. link = urllib.unquote(link)
  696. label = self.cm.ph.getSearchGroups(item, r'''['"]?label['"]?[ ]*:[ ]*['"]([^"^']+)['"]''')[0]
  697. if '://' in link and not link.endswith('.smil'):
  698. linksTab.append({'name': '%s %s' % (serverName, label), 'url':link})
  699. printDBG('_findLinks A')
  700. if 0 == len(linksTab):
  701. printDBG('_findLinks B')
  702. link = self.cm.ph.getSearchGroups(data, linkMarker)[0].replace('\/', '/')
  703. if '://' in link and not link.endswith('.smil'):
  704. linksTab.append({'name':serverName, 'url':link})
  705. return linksTab
  706. def _findLinks2(self, data, baseUrl):
  707. videoUrl = self.cm.ph.getSearchGroups(data, 'type="video/divx"src="(http[^"]+?)"')[0]
  708. if '' != videoUrl: return strwithmeta(videoUrl, {'Referer':baseUrl})
  709. videoUrl = self.cm.ph.getSearchGroups(data, r'''['"]?file['"]?[ ]*[:,][ ]*['"](http[^"^']+)['"][,}\)]''')[0]
  710. if '' != videoUrl: return strwithmeta(videoUrl, {'Referer':baseUrl})
  711. return False
  712. def _parserUNIVERSAL_A(self, baseUrl, embedUrl, _findLinks, _preProcessing=None, httpHeader={}, params={}):
  713. HTTP_HEADER = { 'User-Agent':"Mozilla/5.0", 'Referer':baseUrl }
  714. HTTP_HEADER.update(httpHeader)
  715. if 'embed' not in baseUrl:
  716. video_id = self.cm.ph.getSearchGroups(baseUrl+'/', '/([A-Za-z0-9]{12})[/.]')[0]
  717. url = embedUrl.format(video_id)
  718. else:
  719. url = baseUrl
  720. params = dict(params)
  721. params.update({'header':HTTP_HEADER})
  722. post_data = None
  723. sts, data = self.cm.getPage(url, params, post_data)
  724. if not sts: return False
  725. errMarkers = ['File was deleted', 'File Removed', 'File Deleted.', 'File Not Found']
  726. for errMarker in errMarkers:
  727. if errMarker in data:
  728. SetIPTVPlayerLastHostError(errMarker)
  729. if _preProcessing != None:
  730. data = _preProcessing(data)
  731. #printDBG(data)
  732. # get JS player script code from confirmation page
  733. mrk1 = ">eval("
  734. mrk2 = 'eval("'
  735. if mrk1 in data:
  736. m1 = mrk1
  737. elif mrk2 in data :
  738. m1 = mrk2
  739. else: m1 = "eval("
  740. tmpDataTab = self.cm.ph.getAllItemsBeetwenMarkers(data, m1, '</script>', False)
  741. for tmpData in tmpDataTab:
  742. data2 = tmpData
  743. tmpData = None
  744. # unpack and decode params from JS player script code
  745. tmpData = unpackJSPlayerParams(data2, VIDUPME_decryptPlayerParams)
  746. if tmpData == '':
  747. tmpData = unpackJSPlayerParams(data2, VIDUPME_decryptPlayerParams, 0)
  748. data = data + tmpData
  749. printDBG(data)
  750. return _findLinks(data)
  751. def _parserUNIVERSAL_B(self, url):
  752. printDBG("_parserUNIVERSAL_B url[%s]" % url)
  753. sts, response = self.cm.getPage(url, {'return_data':False})
  754. url = response.geturl()
  755. response.close()
  756. post_data = None
  757. if '/embed' not in url:
  758. sts, data = self.cm.getPage( url, {'header':{'User-Agent': 'Mozilla/5.0'}} )
  759. if not sts: return False
  760. try:
  761. tmp = self.cm.ph.getDataBeetwenMarkers(data, '<form method="post" action="">', '</form>', False, False)[1]
  762. post_data = dict(re.findall(r'<input[^>]*name="([^"]*)"[^>]*value="([^"]*)"[^>]*>', tmp))
  763. except:
  764. printExc()
  765. try:
  766. tmp = dict(re.findall(r'<button[^>]*name="([^"]*)"[^>]*value="([^"]*)"[^>]*>', tmp))
  767. post_data.update(tmp)
  768. except:
  769. printExc()
  770. videoUrl = False
  771. params = {'header':{ 'User-Agent': 'Mozilla/5.0', 'Content-Type':'application/x-www-form-urlencoded','Referer':url} }
  772. try:
  773. sts, data = self.cm.getPage(url, params, post_data)
  774. printDBG(data)
  775. filekey = re.search('flashvars.filekey="([^"]+?)";', data)
  776. if None == filekey:
  777. filekey = re.search("flashvars.filekey=([^;]+?);", data)
  778. filekey = re.search('var {0}="([^"]+?)";'.format(filekey.group(1)), data)
  779. filekey = filekey.group(1)
  780. file = re.search('flashvars.file="([^"]+?)";', data).group(1)
  781. domain = re.search('flashvars.domain="(http[^"]+?)"', data).group(1)
  782. url = domain + '/api/player.api.php?cid2=undefined&cid3=undefined&cid=undefined&user=undefined&pass=undefined&numOfErrors=0'
  783. url = url + '&key=' + urllib.quote_plus(filekey) + '&file=' + urllib.quote_plus(file)
  784. sts, data = self.cm.getPage(url)
  785. videoUrl = re.search("url=([^&]+?)&", data).group(1)
  786. errUrl = domain + '/api/player.api.php?errorCode=404&cid=1&file=%s&cid2=undefined&cid3=undefined&key=%s&numOfErrors=1&user=undefined&errorUrl=%s&pass=undefined' % (urllib.quote_plus(file), urllib.quote_plus(filekey), urllib.quote_plus(videoUrl))
  787. sts, data = self.cm.getPage(errUrl)
  788. errUrl = re.search("url=([^&]+?)&", data).group(1)
  789. if '' != errUrl: url = errUrl
  790. if '' != url:
  791. videoUrl = url
  792. except:
  793. printExc()
  794. return videoUrl
  795. def __parseJWPLAYER_A(self, baseUrl, serverName='', customLinksFinder=None, folowIframe=False):
  796. printDBG("pageParser.__parseJWPLAYER_A serverName[%s], baseUrl[%r]" % (serverName, baseUrl))
  797. linkList = []
  798. tries = 3
  799. while tries > 0:
  800. tries -= 1
  801. HTTP_HEADER = dict(self.HTTP_HEADER)
  802. HTTP_HEADER['Referer'] = baseUrl
  803. sts, data = self.cm.getPage(baseUrl, {'header' : HTTP_HEADER})
  804. if sts:
  805. HTTP_HEADER = dict(self.HTTP_HEADER)
  806. HTTP_HEADER['Referer'] = baseUrl
  807. url = self.cm.ph.getSearchGroups(data, 'iframe[ ]+src="(https?://[^"]*?embed[^"]+?)"')[0]
  808. if '' != url and (serverName in url or folowIframe):
  809. sts, data = self.cm.getPage(url, {'header' : HTTP_HEADER})
  810. else:
  811. url = baseUrl
  812. if sts and '' != data:
  813. try:
  814. sts, data2 = self.cm.ph.getDataBeetwenMarkers(data, 'method="POST"', '</Form>', False, False)
  815. if sts:
  816. post_data = dict(re.findall(r'<input[^>]*name="([^"]*)"[^>]*value="([^"]*)"[^>]*>', data2))
  817. if tries == 0:
  818. try:
  819. sleep_time = self.cm.ph.getSearchGroups(data2, '>([0-9]+?)</span> seconds<')[0]
  820. if '' != sleep_time: time.sleep(int(sleep_time))
  821. except:
  822. printExc()
  823. HTTP_HEADER['Referer'] = url
  824. sts, data = self.cm.getPage(url, {'header' : HTTP_HEADER}, post_data)
  825. if sts:
  826. tmp = self.cm.ph.getAllItemsBeetwenMarkers(data, ">eval(", '</script>')
  827. for tmpItem in tmp:
  828. try:
  829. tmpItem = unpackJSPlayerParams(tmpItem, VIDUPME_decryptPlayerParams)
  830. data = tmpItem + data
  831. except: printExc()
  832. if None != customLinksFinder: linkList = customLinksFinder(data)
  833. if 0 == len(linkList): linkList = self._findLinks(data, serverName)
  834. except:
  835. printExc()
  836. if len(linkList) > 0:
  837. break
  838. return linkList
  839. def parserFIREDRIVE(self,url):
  840. HTTP_HEADER= { 'User-Agent':'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:21.0) Gecko/20100101 Firefox/21.0',
  841. 'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' }
  842. COOKIEFILE = self.COOKIE_PATH + "firedrive.cookie"
  843. url = url.replace('putlocker', 'firedrive').replace('file', 'embed')
  844. HTTP_HEADER['Referer'] = url
  845. sts, data = self.cm.getPage( url, {'header':HTTP_HEADER, 'use_cookie': True, 'save_cookie': True, 'load_cookie': False, 'cookiefile': COOKIEFILE} )
  846. if not sts: return False
  847. if not 'Continue to ' in data: return False
  848. data = re.search('name="confirm" value="([^"]+?)"', data)
  849. if not data: return False
  850. data = {'confirm' : data.group(1)}
  851. sts, data = self.cm.getPage( url, {'header':HTTP_HEADER, 'use_cookie': True, 'save_cookie': True, 'load_cookie': True, 'cookiefile': COOKIEFILE}, data)
  852. if not sts: return False
  853. sts, link_data = CParsingHelper.getDataBeetwenMarkers(data, "function getVideoUrl(){", 'return', False)
  854. if sts: match = re.search("post\('(http[^']+?)'", link_data)
  855. else: match = re.search("file: '(http[^']+?)'", data)
  856. if not match: match = re.search("file: loadURL\('(http[^']+?)'", data)
  857. if not match: return False
  858. url = match.group(1)
  859. printDBG('parserFIREDRIVE url[%s]' % url)
  860. return url
  861. def parserMEGUSTAVID(self,url):
  862. query_data = { 'url': url, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True }
  863. link = self.cm.getURLRequestData(query_data)
  864. match = re.compile('value="config=(.+?)">').findall(link)
  865. if len(match) > 0:
  866. p = match[0].split('=')
  867. url = "http://megustavid.com/media/nuevo/player/playlist.php?id=" + p[1]
  868. query_data = { 'url': url, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True }
  869. link = self.cm.getURLRequestData(query_data)
  870. match = re.compile('<file>(.+?)</file>').findall(link)
  871. if len(match) > 0:
  872. return match[0]
  873. else:
  874. return False
  875. else:
  876. return False
  877. def parserSPROCKED(self,url):
  878. url = url.replace('embed', 'show')
  879. query_data = { 'url': url, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True }
  880. link = self.cm.getURLRequestData(query_data)
  881. match = re.search("""url: ['"](.+?)['"],.*\nprovider""",link)
  882. if match: return match.group(1)
  883. else: return False
  884. def parserWGRANE(self,url):
  885. # extract video hash from given url
  886. sts, data = self.cm.getPage(url)
  887. if not sts: return False
  888. agree = ''
  889. if 'controversial_content_agree' in data: agree = 'controversial_content_agree'
  890. elif 'adult_content_agree' in data: agree = 'adult_content_agree'
  891. if '' != agree:
  892. vidHash = re.search("([0-9a-fA-F]{32})$", url)
  893. if not vidHash: return False
  894. params = {'use_cookie': True, 'load_cookie':False, 'save_cookie':False}
  895. url = "http://www.wgrane.pl/index.html?%s=%s" % (agree, vidHash.group(1))
  896. sts, data = self.cm.getPage(url, params)
  897. if not sts: return False
  898. tmp = re.search('''["'](http[^"^']+?/video/[^"^']+?\.mp4[^"^']*?)["']''', data)
  899. if tmp: return tmp.group(1)
  900. data = re.search("<meta itemprop='contentURL' content='([^']+?)'", data)
  901. if not data: return False
  902. url = clean_html(data.group(1))
  903. return url
  904. def parserCDA(self, inUrl):
  905. def _decorateUrl(inUrl, host, referer):
  906. # prepare extended link
  907. retUrl = strwithmeta( inUrl )
  908. retUrl.meta['Host'] = host
  909. retUrl.meta['Referer'] = referer
  910. retUrl.meta['Cookie'] = "PHPSESSID=1"
  911. retUrl.meta['iptv_proto'] = 'http'
  912. retUrl.meta['iptv_urlwithlimit'] = False
  913. retUrl.meta['iptv_livestream'] = False
  914. retUrl.meta['iptv_buffering'] = "required" #"required" # required to handle Cookie
  915. return retUrl
  916. vidMarker = '/video/'
  917. videoUrls = []
  918. uniqUrls = []
  919. tmpUrls = []
  920. if vidMarker not in inUrl:
  921. sts, data = self.cm.getPage(inUrl)
  922. if sts:
  923. sts,match = CParsingHelper.getDataBeetwenMarkers(data, "Link do tego video:", '</a>', False)
  924. if sts: match = self.cm.ph.getSearchGroups(match, 'href="([^"]+?)"')[0]
  925. else: match = self.cm.ph.getSearchGroups(data, "link[ ]*?:[ ]*?'([^']+?/video/[^']+?)'")[0]
  926. if match.startswith('http'): inUrl = match
  927. if vidMarker in inUrl:
  928. vid = self.cm.ph.getSearchGroups(inUrl + '/', "/video/([^/]+?)/")[0]
  929. inUrl = 'http://ebd.cda.pl/620x368/' + vid
  930. # extract qualities
  931. sts, data = self.cm.getPage(inUrl)
  932. if sts:
  933. sts, data = CParsingHelper.getDataBeetwenMarkers(data, 'Jakość:', '</div>', False)
  934. if sts:
  935. data = re.findall('<a[^>]+?href="([^"]+?)"[^>]*?>([^<]+?)</a>', data)
  936. for urlItem in data:
  937. tmpUrls.append({'name':'cda.pl ' + urlItem[1], 'url':urlItem[0]})
  938. if 0 == len(tmpUrls):
  939. tmpUrls.append({'name':'cda.pl', 'url':inUrl})
  940. def __appendVideoUrl(params):
  941. if params['url'] not in uniqUrls:
  942. videoUrls.append(params)
  943. uniqUrls.append(params['url'])
  944. for urlItem in tmpUrls:
  945. if urlItem['url'].startswith('/'): inUrl = 'http://www.cda.pl/' + urlItem['url']
  946. else: inUrl = urlItem['url']
  947. sts, pageData = self.cm.getPage(inUrl)
  948. if not sts: continue
  949. #with open('/home/sulge/movie/test.txt', 'r') as cfile:
  950. # pageData = cfile.read()
  951. tmpData = self.cm.ph.getDataBeetwenMarkers(pageData, "eval(", '</script>', False)[1]
  952. if tmpData != '':
  953. m1 = '$.get'
  954. if m1 in tmpData:
  955. tmpData = tmpData[:tmpData.find(m1)].strip() + '</script>'
  956. try: tmpData = unpackJSPlayerParams(tmpData, TEAMCASTPL_decryptPlayerParams, 0, True, True)
  957. except Exception: pass
  958. #printDBG(tmpData)
  959. tmpData += pageData
  960. data = CParsingHelper.getDataBeetwenReMarkers(tmpData, re.compile('''modes['"]?[\s]*:'''), re.compile(']'), False)[1]
  961. data = re.compile("""file:[\s]*['"]([^'^"]+?)['"]""").findall(data)
  962. if 0 < len(data) and data[0].startswith('http'): __appendVideoUrl( {'name': urlItem['name'] + ' flv', 'url':_decorateUrl(data[0], 'cda.pl', urlItem['url']) } )
  963. if 1 < len(data) and data[1].startswith('http'): __appendVideoUrl( {'name': urlItem['name'] + ' mp4', 'url':_decorateUrl(data[1], 'cda.pl', urlItem['url']) } )
  964. if 0 == len(data):
  965. data = CParsingHelper.getDataBeetwenReMarkers(tmpData, re.compile('video:[\s]*{'), re.compile('}'), False)[1]
  966. data = self.cm.ph.getSearchGroups(data, "'(http[^']+?(:?\.mp4|\.flv)[^']*?)'")[0]
  967. if '' != data:
  968. type = ' flv '
  969. if '.mp4' in data:
  970. type = ' mp4 '
  971. __appendVideoUrl( {'name': urlItem['name'] + type, 'url':_decorateUrl(data, 'cda.pl', urlItem['url']) } )
  972. #if len(videoUrls):
  973. # videoUrls = [videoUrls[0]]
  974. return videoUrls
  975. def parserDWN(self,url):
  976. if "play4.swf" in url:
  977. match = re.search("play4.swf([^']+?)',", url+"',")
  978. else:
  979. sts, url = self.cm.getPage(url)
  980. if not sts: return False
  981. match = re.search('src="([^"]+?)" width=', url)
  982. if match:
  983. sts, url = self.cm.getPage( match.group(1) )
  984. if not sts: return False
  985. match = re.search("play4.swf([^']+?)',", url)
  986. if match:
  987. url = 'http://st.dwn.so/xml/videolink.php' + match.group(1)
  988. sts, data = self.cm.getPage(url)
  989. if not sts: return False
  990. match = re.search('un="([^"]+?),0"', data)
  991. if match:
  992. linkvideo = 'http://' + match.group(1)
  993. printDBG("parserDWN directURL [%s]" % linkvideo)
  994. return linkvideo
  995. return False
  996. def parserANYFILES(self, url):
  997. from anyfilesapi import AnyFilesVideoUrlExtractor
  998. self.anyfiles = AnyFilesVideoUrlExtractor()
  999. id = self.cm.ph.getSearchGroups(url+'|', 'id=([0-9]+?)[^0-9]')[0]
  1000. if id != '':
  1001. url = 'http://video.anyfiles.pl/videos.jsp?id=' + id
  1002. retVal = self.anyfiles.getVideoUrl(url)
  1003. return retVal
  1004. def parserWOOTLY(self,url):
  1005. query_data = { 'url': url, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True }
  1006. link = self.cm.getURLRequestData(query_data)
  1007. c = re.search("""c.value="(.+?)";""",link)
  1008. if c:
  1009. cval = c.group(1)
  1010. else:
  1011. return False
  1012. match = re.compile("""<input type=['"]hidden['"] value=['"](.+?)['"].+?name=['"](.+?)['"]""").findall(link)
  1013. if len(match) > 0:
  1014. postdata = {};
  1015. for i in range(len(match)):
  1016. if (len(match[i][0])) > len(cval):
  1017. postdata[cval] = match[i][1]
  1018. else:
  1019. postdata[match[i][0]] = match[i][1]
  1020. self.COOKIEFILE = self.COOKIE_PATH + "wootly.cookie"
  1021. query_data = { 'url': url, 'use_host': False, 'use_cookie': True, 'save_cookie': True, 'load_cookie': False, 'cookiefile': self.COOKIEFILE, 'use_post': True, 'return_data': True }
  1022. link = self.cm.getURLRequestData(query_data, postdata)
  1023. match = re.search("""<video.*\n.*src=['"](.+?)['"]""",link)
  1024. if match:
  1025. return match.group(1)
  1026. else:
  1027. return False
  1028. else:
  1029. return False
  1030. def parserVIDEOWEED(self, url):
  1031. return self._parserUNIVERSAL_B(url)
  1032. def parserNOVAMOV(self, url):
  1033. return self._parserUNIVERSAL_B(url)
  1034. def parserNOWVIDEO(self, url):
  1035. urlTab = []
  1036. if '/mobile/video.php?id' in url:
  1037. sts, data = self.cm.getPage(url)
  1038. if sts:
  1039. data = re.compile('<source ([^>]*?)>').findall(data)
  1040. for item in data:
  1041. type = self.cm.ph.getSearchGroups(item, 'type="([^"]+?)"')[0]
  1042. if 'video' not in type: continue
  1043. url = self.cm.ph.getSearchGroups(item, 'src="([^"]+?)"')[0]
  1044. name = url.split('?')[0].split('.')[-1]
  1045. urlTab.append({'name':type, 'url':url})
  1046. if len(urlTab): return urlTab
  1047. tmp = self._parserUNIVERSAL_B(url)
  1048. if isinstance(tmp, basestring) and 0 < len(tmp):
  1049. tmp += '?client=FLASH'
  1050. return tmp
  1051. def parserSOCKSHARE(self,url):
  1052. query_data = { 'url': url.replace('file', 'embed'), 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True }
  1053. link = self.cm.getURLRequestData(query_data)
  1054. r = re.search('value="(.+?)" name="fuck_you"', link)
  1055. if r:
  1056. self.COOKIEFILE = self.COOKIE_PATH + "sockshare.cookie"
  1057. postdata = {'fuck_you' : r.group(1), 'confirm' : 'Close Ad and Watch as Free User'}
  1058. query_data = { 'url': url.replace('file', 'embed'), 'use_host': False, 'use_cookie': True, 'save_cookie': True, 'load_cookie': False, 'cookiefile': self.COOKIEFILE, 'use_post': True, 'return_data': True }
  1059. link = self.cm.getURLRequestData(query_data, postdata)
  1060. match = re.compile("playlist: '(.+?)'").findall(link)
  1061. if len(match) > 0:
  1062. url = "http://www.sockshare.com" + match[0]
  1063. query_data = { 'url': url, 'use_host': False, 'use_cookie': True, 'save_cookie': False, 'load_cookie': True, 'cookiefile': self.COOKIEFILE, 'use_post': False, 'return_data': True }
  1064. link = self.cm.getURLRequestData(query_data)
  1065. match = re.compile('</link><media:content url="(.+?)" type="video').findall(link)
  1066. if len(match) > 0:
  1067. url = match[0].replace('&amp;','&')
  1068. return url
  1069. else:
  1070. return False
  1071. else:
  1072. return False
  1073. else:
  1074. return False
  1075. def parserRAPIDVIDEO(self,url):
  1076. query_data = { 'url': url, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True }
  1077. link = self.cm.getURLRequestData(query_data)
  1078. #"jw_set('http://176.9.7.56:8080/v/bc71afa327b1351b2d9abe5827aa97dc/240/130219976TEBYU50H0NN.flv','240p','176.9.7.56');"
  1079. match = re.compile("jw_set\('(.+?)','(.+?)','.+?'\);").findall(link)
  1080. if len(match) > 0:
  1081. return match[0][0]
  1082. else:
  1083. return False
  1084. def parserVIDEOSLASHER(self, url):
  1085. self.COOKIEFILE = self.COOKIE_PATH + "videoslasher.cookie"
  1086. query_data = { 'url': url.replace('embed', 'video'), 'use_host': False, 'use_cookie': True, 'save_cookie': True, 'load_cookie': False, 'cookiefile': self.COOKIEFILE, 'use_post': True, 'return_data': True }
  1087. postdata = {'confirm': 'Close Ad and Watch as Free User', 'foo': 'bar'}
  1088. data = self.cm.getURLRequestData(query_data, postdata)
  1089. match = re.compile("playlist: '/playlist/(.+?)'").findall(data)
  1090. if len(match)>0:
  1091. query_data = { 'url': 'http://www.videoslasher.com//playlist/' + match[0], 'use_host': False, 'use_cookie': True, 'save_cookie': True, 'load_cookie': True, 'cookiefile': self.COOKIEFILE, 'use_post': True, 'return_data': True }
  1092. data = self.cm.getURLRequestData(query_data)
  1093. match = re.compile('<title>Video</title>.*?<media:content url="(.+?)"').findall(data)
  1094. if len(match)>0:
  1095. sid = self.cm.getCookieItem(self.COOKIEFILE,'authsid')
  1096. if sid != '':
  1097. streamUrl = urlparser.decorateUrl(match[0], {'Cookie':"authsid=%s" % sid, 'iptv_buffering':'required'})
  1098. return streamUrl
  1099. else:
  1100. return False
  1101. else:
  1102. return False
  1103. else:
  1104. return False
  1105. def parserDAILYMOTION(self, baseUrl):
  1106. # https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/dailymotion.py
  1107. COOKIEFILE = self.COOKIE_PATH + "dailymotion.cookie"
  1108. _VALID_URL = r'(?i)(?:https?://)?(?:(www|touch)\.)?dailymotion\.[a-z]{2,3}/(?:(embed|#)/)?video/(?P<id>[^/?_]+)'
  1109. mobj = re.match(_VALID_URL, baseUrl)
  1110. video_id = mobj.group('id')
  1111. url = 'http://www.dailymotion.com/embed/video/' + video_id
  1112. familyUrl = 'http://www.dailymotion.com/family_filter?enable=false&urlback=' + urllib.quote_plus('/embed/video/' + video_id)
  1113. sts, data = self.cm.getPage(url, {'use_cookie': True, 'save_cookie': False, 'load_cookie': False, 'cookiefile': COOKIEFILE})
  1114. if not sts or "player" not in data:
  1115. sts, data = self.cm.getPage(familyUrl, {'use_cookie': True, 'save_cookie': False, 'load_cookie': False, 'cookiefile': COOKIEFILE})
  1116. if not sts: return []
  1117. vidTab = []
  1118. player_v5 = self.cm.ph.getSearchGroups(data, r'playerV5\s*=\s*dmp\.create\([^,]+?,\s*({.+?})\);')[0]
  1119. if '' != player_v5:
  1120. player_v5 = byteify(json.loads(player_v5))
  1121. printDBG(player_v5)
  1122. player_v5 = player_v5['metadata']['qualities']
  1123. for quality, media_list in player_v5.items():
  1124. for media in media_list:
  1125. media_url = media.get('url')
  1126. if not media_url:
  1127. continue
  1128. type_ = media.get('type')
  1129. if type_ == 'application/vnd.lumberjack.manifest':
  1130. continue
  1131. if type_ == 'application/x-mpegURL' or media_url.split('?')[-1].endswith('m3u8'):
  1132. continue
  1133. tmpTab = getDirectM3U8Playlist(media_url, False)
  1134. for tmp in tmpTab:
  1135. vidTab.append({'name':'dailymotion.com: %s hls' % (tmp.get('bitrate', '0')), 'url':tmp['url']})
  1136. else:
  1137. vidTab.append({'name':'dailymotion.com: %s' % quality, 'url':media_url})
  1138. if 0 == len(vidTab):
  1139. data = CParsingHelper.getDataBeetwenMarkers(data, 'id="player"', '</script>', False)[1].replace('\/', '/')
  1140. match = re.compile('"stream_h264.+?url":"(http[^"]+?H264-)([^/]+?)(/[^"]+?)"').findall(data)
  1141. for i in range(len(match)):
  1142. url = match[i][0] + match[i][1] + match[i][2]
  1143. name = match[i][1]
  1144. vidTab.append({'name': 'dailymotion.com: ' + name, 'url':url})
  1145. return vidTab[::-1]
  1146. def parserSIBNET(self, baseUrl):
  1147. printDBG("parserSIBNET url[%s]" % baseUrl)
  1148. videoUrls = []
  1149. videoid = self.cm.ph.getSearchGroups(baseUrl+'|', """videoid=([0-9]+?)[^0-9]""")[0]
  1150. #baseUrl.split('?')[0].endswith('.swf') and
  1151. if '' != videoid: configUrl = "http://video.sibnet.ru/shell_config_xml.php?videoid=%s&partner=null&playlist_position=null&playlist_size=0&related_albid=0&related_tagid=0&related_ids=null&repeat=null&nocache" % (videoid)
  1152. else: configUrl = baseUrl
  1153. # get video for android
  1154. HTTP_HEADER = dict(self.HTTP_HEADER)
  1155. HTTP_HEADER['User-Agent'] = "Mozilla/5.0 (Linux; U; Android 4.1.1; en-us; androVM for VirtualBox ('Tablet' version with phone caps) Build/JRO03S) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30"
  1156. sts, data = self.cm.getPage(configUrl, {'header':HTTP_HEADER})
  1157. if sts:
  1158. url = self.cm.ph.getSearchGroups(data, """<file>(http[^<]+?\.mp4)</file>""")[0]
  1159. if '' == url: url = self.cm.ph.getSearchGroups(data, """(http[^"']+?\.mp4)""")[0]
  1160. if '' != url: videoUrls.append({'name':'video.sibnet.ru: mp4', 'url':url})
  1161. # get video for PC
  1162. sts, data = self.cm.getPage(configUrl)
  1163. if sts:
  1164. url = self.cm.ph.getSearchGroups(data, """<file>(http[^<]+?)</file>""")[0]
  1165. if '' == url: url = self.cm.ph.getSearchGroups(data, """['"]file['"][ ]*?:[ ]*?['"]([^"^']+?)['"]""")[0]
  1166. if url.split('?')[0].endswith('.m3u8'):
  1167. retTab = getDirectM3U8Playlist(url)
  1168. for item in retTab:
  1169. videoUrls.append({'name':'video.sibnet.ru: ' + item['name'], 'url':item['url']})
  1170. elif '' != url: videoUrls.append({'name':'video.sibnet.ru: ' + url.split('.')[-1], 'url':url})
  1171. return videoUrls
  1172. '''
  1173. # Old code not used
  1174. mid = re.search('videoid=(.+?)$',url)
  1175. ourl = 'http://video.sibnet.ru'
  1176. movie = 'http://video.sibnet.ru/v/qwerty/'+mid.group(1)+'.mp4?start=0'
  1177. query_data = { 'url': ourl+'/video'+mid.group(1), 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True }
  1178. link = self.cm.getURLRequestData(query_data)
  1179. match = re.search("'file':'(.+?)'",link)
  1180. if match:
  1181. sUrl = match.group(1)
  1182. if not sUrl.startswith('http'):
  1183. sUrl = ourl + sUrl
  1184. return sUrl
  1185. else:
  1186. return False
  1187. '''
  1188. def parserVK(self, url):
  1189. printDBG("parserVK url[%s]" % url)
  1190. sts, data = self.cm.getPage(url)
  1191. if not sts: return False
  1192. movieUrls = []
  1193. item = self.cm.ph.getSearchGroups(data, '''['"]?cache([0-9]+?)['"]?[=:]['"]?(http[^"]+?\.mp4[^;^"^']*)[;"']''', 2)
  1194. if '' != item[1]:
  1195. cacheItem = { 'name': 'vk.com: ' + item[0] + 'p (cache)', 'url':item[1].replace('\\/', '/').encode('UTF-8') }
  1196. else: cacheItem = None
  1197. tmpTab = re.findall('''['"]?url([0-9]+?)['"]?[=:]['"]?(http[^"]+?\.mp4[^;^"^']*)[;"']''', data)
  1198. ##prepare urls list without duplicates
  1199. for item in tmpTab:
  1200. item = list(item)
  1201. if item[1].endswith('&amp'): item[1] = item[1][:-4]
  1202. item[1] = item[1].replace('\\/', '/')
  1203. found = False
  1204. for urlItem in movieUrls:
  1205. if item[1] == urlItem['url']:
  1206. found = True
  1207. break
  1208. if not found:
  1209. movieUrls.append({ 'name': 'vk.com: ' + item[0] + 'p', 'url':item[1].encode('UTF-8') })
  1210. ##move default format to first position in urls list
  1211. ##default format should be a configurable
  1212. DEFAULT_FORMAT = 'vk.com: 360p'
  1213. defaultItem = None
  1214. for idx in range(len(movieUrls)):
  1215. if DEFAULT_FORMAT == movieUrls[idx]['name']:
  1216. defaultItem = movieUrls[idx]
  1217. del movieUrls[idx]
  1218. break
  1219. if None != defaultItem:
  1220. movieUrls.insert(0, defaultItem)
  1221. if None != cacheItem:
  1222. movieUrls.insert(0, cacheItem)
  1223. return movieUrls
  1224. def parserPETEAVA(self, url):
  1225. mid = re.search("hd_file=(.+?_high.mp4)&", url)
  1226. movie = "http://content.peteava.ro/video/"+mid.group(1)+"?token=PETEAVARO"
  1227. return movie
  1228. def parserVPLAY(self, url):
  1229. vid = re.search("key=(.+?)$", url)
  1230. query_data = { 'url': 'http://www.vplay.ro/play/dinosaur.do', 'use_host': False, 'use_cookie': False, 'use_post': True, 'return_data': True }
  1231. postdata = {'key':vid.group(1)}
  1232. link = self.cm.getURLRequestData(query_data, postdata)
  1233. movie = re.search("nqURL=(.+?)&", link)
  1234. if movie:
  1235. return movie.group(1)
  1236. else:
  1237. return False
  1238. def parserIITV(self, url):
  1239. query_data = { 'url': url, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True }
  1240. query_data_non = { 'url': url + '.html?i&e&m=iitv', 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True }
  1241. if 'streamo' in url:
  1242. match = re.compile("url: '(.+?)',").findall(self.cm.getURLRequestData(query_data))
  1243. if 'nonlimit' in url:
  1244. match = re.compile('url: "(.+?)", provider:').findall(self.cm.getURLRequestData(query_data_non))
  1245. if len(match) > 0:
  1246. linkVideo = match[0]
  1247. print ('linkVideo ' + linkVideo)
  1248. return linkVideo
  1249. else:
  1250. print ('Przepraszamy','Obecnie zbyt dużo osób ogląda film za pomocą', 'darmowego playera premium.', 'Sproboj ponownie za jakis czas')
  1251. return False
  1252. def parserDIVXSTAGE(self,url):
  1253. return self._parserUNIVERSAL_B(url)
  1254. def parserBESTREAMS(self, baseUrl):
  1255. printDBG("parserBESTREAMS baseUrl[%s]" % baseUrl)
  1256. USER_AGENT = 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10'
  1257. video_id = self.cm.ph.getSearchGroups(baseUrl+'/', '[/-]([A-Za-z0-9]{12})[/-]')[0]
  1258. url = 'http://bestreams.net/{0}'.format(video_id)
  1259. HTTP_HEADER = dict(self.HTTP_HEADER)
  1260. HTTP_HEADER['User-Agent'] = USER_AGENT
  1261. HTTP_HEADER['Referer'] = baseUrl
  1262. sts, data = self.cm.getPage(baseUrl, {'header' : HTTP_HEADER})
  1263. tries = 0
  1264. while tries < 3:
  1265. tries += 1
  1266. try:
  1267. sleep_time = self.cm.ph.getSearchGroups(data, '>([0-9])</span> seconds<')[0]
  1268. sleep_time = int(sleep_time)
  1269. if sleep_time < 12: time.sleep(sleep_time)
  1270. except:
  1271. printExc()
  1272. sts, data = self.cm.ph.getDataBeetwenMarkers(data, 'method="POST"', '</Form>', False, False)
  1273. if not sts: continue
  1274. post_data = dict(re.findall(r'<input[^>]*name="([^"]*)"[^>]*value="([^"]*)"[^>]*>', data))
  1275. HTTP_HEADER['Referer'] = url
  1276. sts, data = self.cm.getPage(url, {'header' : HTTP_HEADER}, post_data)
  1277. if not sts: continue
  1278. #printDBG(data)
  1279. try:
  1280. tmp = self.cm.ph.getDataBeetwenMarkers(data, 'id="file_title"', '</a>', False)[1]
  1281. videoUrl = self.cm.ph.getSearchGroups(tmp, 'href="(http[^"]+?)"')[0]
  1282. if '' == videoUrl: continue
  1283. return urlparser.decorateUrl(videoUrl, {'User-Agent':USER_AGENT})
  1284. except:
  1285. printExc()
  1286. return False
  1287. def parserTUBECLOUD(self, url):
  1288. self.COOKIEFILE = self.COOKIE_PATH + "tubecloud.cookie"
  1289. query_data = { 'url': url, 'use_host': False, 'use_cookie': True, 'save_cookie': True, 'load_cookie': False, 'cookiefile': self.COOKIEFILE, 'use_post': False, 'return_data': True }
  1290. link = self.cm.getURLRequestData(query_data)
  1291. ID = re.search('name="id" value="(.+?)">', link)
  1292. FNAME = re.search('name="fname" value="(.+?)">', link)
  1293. HASH = re.search('name="hash" value="(.+?)">', link)
  1294. if ID and FNAME and HASH > 0:
  1295. time.sleep(105)
  1296. postdata = {'fname' : FNAME.group(1), 'hash' : HASH.group(1), 'id' : ID.group(1), 'imhuman' : 'Proceed to video', 'op' : 'download1', 'referer' : url, 'usr_login' : '' }
  1297. query_data = { 'url': url, 'use_host': False, 'use_cookie': True, 'save_cookie': False, 'load_cookie': True, 'cookiefile': self.COOKIEFILE, 'use_post': True, 'return_data': True }
  1298. link = self.cm.getURLRequestData(query_data, postdata)
  1299. match = re.compile('file: "(.+?)"').findall(link)
  1300. if len(match) > 0:
  1301. linkvideo = match[0]
  1302. return linkvideo
  1303. else:
  1304. return self.parserPLAYEDTO(url)
  1305. else:
  1306. return self.parserPLAYEDTO(url)
  1307. def parserPLAYEDTO(self, url):
  1308. sts, data = self.cm.getPage(url)
  1309. url = re.search('file: "(http[^"]+?)"', data)
  1310. if url:
  1311. return url.group(1)
  1312. return False
  1313. def parserFREEDISC(self, baseUrl):
  1314. linksTab = []
  1315. COOKIE_FILE = GetCookieDir('freedicpl.cookie')
  1316. HTTP_HEADER= { 'User-Agent':'Mozilla/5.0'}
  1317. params = {'header':HTTP_HEADER, 'cookiefile':COOKIE_FILE, 'use_cookie': True, 'save_cookie':True, 'load_cookie':False}
  1318. sts, data = self.cm.getPage(baseUrl, params)
  1319. if not sts: return linksTab
  1320. tmpUrls = []
  1321. try:
  1322. tmp = self.cm.ph.getDataBeetwenMarkers(data, '<script type="application/ld+json">', '</script>', False)[1]
  1323. tmp = byteify(json.loads(tmp))
  1324. tmp = tmp['embedUrl'].split('?file=')
  1325. if tmp[1].startswith('http'):
  1326. linksTab.append({'name':'freedisc.pl', 'url': urlparser.decorateUrl(tmp[1], {'Referer':tmp[0], 'User-Agent':HTTP_HEADER['User-Agent']})})
  1327. tmpUrls.append(tmp[1])
  1328. except:
  1329. printExc()
  1330. videoUrl = self.cm.ph.getSearchGroups(data, '''<iframe[^>]+?src=["'](http[^"^']+?/embed/[^"^']+?)["']''', 1, True)[0]
  1331. if '' == videoUrl: return linksTab
  1332. params['load_cookie'] = True
  1333. params['header']['Referer'] = baseUrl
  1334. sts, data = self.cm.getPage(videoUrl, params)
  1335. if not sts: return linksTab
  1336. videoUrl = self.cm.ph.getSearchGroups(data, '''data-video-url=["'](http[^"^']+?)["']''', 1, True)[0]
  1337. if videoUrl.startswith('http') and videoUrl not in tmpUrls:
  1338. linksTab.append({'name':'freedisc.pl', 'url': urlparser.decorateUrl(videoUrl, {'Referer':'http://freedisc.pl/static/player/v612/jwplayer.flash.swf', 'User-Agent':HTTP_HEADER['User-Agent']})})
  1339. return linksTab
  1340. def parserGINBIG(self,url):
  1341. query_data = { 'url': url, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True }
  1342. link = self.cm.getURLRequestData(query_data)
  1343. ID = re.search('name="id" value="(.+?)">', link)
  1344. FNAME = re.search('name="fname" value="(.+?)">', link)
  1345. if ID and FNAME > 0:
  1346. postdata = { 'op': 'download1', 'id': ID.group(1), 'fname': FNAME.group(1), 'referer': url, 'method_free': 'Free Download', 'usr_login': '' }
  1347. query_data = { 'url': url, 'use_host': False, 'use_cookie': False, 'use_post': True, 'return_data': True }
  1348. link = self.cm.getURLRequestData(query_data, postdata)
  1349. data = link.replace('|', '<>')
  1350. PL = re.search('<>player<>(.+?)<>flvplayer<>', data)
  1351. HS = re.search('video<>(.+?)<>(.+?)<>file<>', data)
  1352. if PL and HS > 0:
  1353. linkVideo = 'http://' + PL.group(1) + '.ginbig.com:' + HS.group(2) + '/d/' + HS.group(1) + '/video.mp4?start=0'
  1354. print ('linkVideo ' + linkVideo)
  1355. return linkVideo
  1356. else:
  1357. return False
  1358. else:
  1359. return False
  1360. def parserQFER(self, url):
  1361. query_data = { 'url': url, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True }
  1362. match = re.compile('"PSST",url: "(.+?)"').findall(self.cm.getURLRequestData(query_data))
  1363. if len(match) > 0:
  1364. linkVideo = match[0]
  1365. print ('linkVideo ' + linkVideo)
  1366. return linkVideo
  1367. else:
  1368. return False
  1369. def parserSTREAMCLOUD(self, baseUrl):
  1370. printDBG("parserSTREAMCLOUD [%s]" % baseUrl)
  1371. # code from https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/streamcloud.py
  1372. _VALID_URL = r'https?://streamcloud\.eu/(?P<id>[a-zA-Z0-9_-]+)(?:/(?P<fname>[^#?]*)\.html)?'
  1373. mobj = re.match(_VALID_URL, baseUrl)
  1374. video_id = mobj.group('id')
  1375. url = 'http://streamcloud.eu/%s' % video_id
  1376. sts, data = self.cm.getPage(url)
  1377. if not sts: return False
  1378. fields = re.findall(r'''(?x)<input\s+
  1379. type="(?:hidden|submit)"\s+
  1380. name="([^"]+)"\s+
  1381. (?:id="[^"]+"\s+)?
  1382. value="([^"]*)"
  1383. ''', data)
  1384. time.sleep(12)
  1385. sts, data = self.cm.getPage(url, {}, fields)
  1386. if not sts: return False
  1387. file = self.cm.ph.getSearchGroups(data, r'''['"]?file['"]?[ ]*:[ ]*['"]([^"^']+)['"],''')[0]
  1388. if file.startswith('http'): return file
  1389. return False
  1390. def parserLIMEVIDEO(self,url):
  1391. query_data = { 'url': url, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True }
  1392. link = self.cm.getURLRequestData(query_data)
  1393. ID = re.search('name="id" value="(.+?)">', link)
  1394. FNAME = re.search('name="fname" value="(.+?)">', link)
  1395. if ID and FNAME > 0:
  1396. time.sleep(205)
  1397. postdata = {'fname' : FNAME.group(1), 'id' : ID.group(1), 'method_free' : 'Continue to Video', 'op' : 'download1', 'referer' : url, 'usr_login' : '' }
  1398. query_data = { 'url': url, 'use_host': False, 'use_cookie': False, 'use_post': True, 'return_data': True }
  1399. link = self.cm.getURLRequestData(query_data, postdata)
  1400. ID = re.search('name="id" value="(.+?)">', link)
  1401. RAND = re.search('name="rand" value="(.+?)">', link)
  1402. table = self.captcha.textCaptcha(link)
  1403. value = table[0][0] + table [1][0] + table [2][0] + table [3][0]
  1404. code = self.cm.html_entity_decode(value)
  1405. print ('captcha-code :' + code)
  1406. if ID and RAND > 0:
  1407. postdata = {'rand' : RAND.group(1), 'id' : ID.group(1), 'method_free' : 'Continue to Video', 'op' : 'download2', 'referer' : url, 'down_direct' : '1', 'code' : code, 'method_premium' : '' }
  1408. query_data = { 'url': url, 'use_host': False, 'use_cookie': False, 'use_post': True, 'return_data': True }
  1409. link = self.cm.getURLRequestData(query_data, postdata)
  1410. data = link.replace('|', '<>')
  1411. PL = re.search('<>player<>video<>(.+?)<>(.+?)<>(.+?)<><>(.+?)<>flvplayer<>', data)
  1412. HS = re.search('image<>(.+?)<>(.+?)<>(.+?)<>file<>', data)
  1413. if PL and HS > 0:
  1414. linkVideo = 'http://' + PL.group(4) + '.' + PL.group(3) + '.' + PL.group(2) + '.' + PL.group(1) + ':' + HS.group(3) + '/d/' + HS.group(2) + '/video.' + HS.group(1)
  1415. print ('linkVideo :' + linkVideo)
  1416. return linkVideo
  1417. else:
  1418. return False
  1419. else:
  1420. return False
  1421. else:
  1422. return False
  1423. def parserSCS(self,url):
  1424. query_data = { 'url': url, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True }
  1425. link = self.cm.getURLRequestData(query_data)
  1426. ID = re.search('"(.+?)"; ccc', link)
  1427. if ID > 0:
  1428. postdata = {'f' : ID.group(1) }
  1429. query_data = { 'url': 'http://scs.pl/getVideo.html', 'use_host': False, 'use_cookie': False, 'use_post': True, 'return_data': True }
  1430. link = self.cm.getURLRequestData(query_data, postdata)
  1431. match = re.compile("url: '(.+?)',").findall(link)
  1432. if len(match) > 0:
  1433. linkVideo = match[0]
  1434. print ('linkVideo ' + linkVideo)
  1435. return linkVideo
  1436. else:
  1437. print ('Przepraszamy','Obecnie zbyt dużo osób ogląda film za pomocą', 'darmowego playera premium.', 'Sproboj ponownie za jakis czas')
  1438. return False
  1439. else:
  1440. return False
  1441. def parserYOUWATCH(self, baseUrl):
  1442. if 'embed' in baseUrl:
  1443. url = baseUrl
  1444. else:
  1445. url = baseUrl.replace('org/', 'org/embed-').replace('to/', 'to/embed-') + '.html'
  1446. COOKIE_FILE = GetCookieDir('youwatchorg.cookie')
  1447. HTTP_HEADER= { 'User-Agent':'Mozilla/5.0'}
  1448. params = {'header':HTTP_HEADER, 'cookiefile':COOKIE_FILE, 'use_cookie': True, 'save_cookie':True, 'load_cookie':True}
  1449. tries = 0
  1450. while tries < 3:
  1451. tries += 1
  1452. sts, data = self.cm.getPage(url, params)
  1453. if not sts: return False
  1454. if 'sources:' in data:
  1455. break
  1456. else:
  1457. params['header']['Referer'] = url
  1458. url = self.cm.ph.getSearchGroups(data, '<iframe[^>]*?src="(http[^"]+?)"', 1, True)[0].replace('\n', '')
  1459. try:
  1460. linksTab = self._findLinks(data)
  1461. if len(linksTab):
  1462. for idx in range(len(linksTab)):
  1463. linksTab[idx]['url'] = urlparser.decorateUrl(linksTab[idx]['url'], {'User-Agent':HTTP_HEADER['User-Agent'],'Referer': url})
  1464. return linksTab
  1465. except:
  1466. pass
  1467. def rc4(e, code):
  1468. d = base64.b64decode(base64.b64decode(base64.b64decode(code)))
  1469. b = []
  1470. for a in range(256):
  1471. b.append(a)
  1472. c = 0
  1473. for a in range(256):
  1474. c = (c + b[a] + ord(d[a % len(d)])) % 256
  1475. f = b[a]
  1476. b[a] = b[c]
  1477. b[c] = f
  1478. a = 0
  1479. c = 0
  1480. d = 0
  1481. g = ""
  1482. for d in range(len(e)):
  1483. a = (a + 1) % 256
  1484. c = (c + b[a]) % 256
  1485. f = b[a]
  1486. b[a] = b[c]
  1487. b[c] = f
  1488. g += chr(ord(e[d]) ^ b[(b[a] + b[c]) % 256])
  1489. return g
  1490. def link(e, code):
  1491. e = base64.b64decode(base64.b64decode(e))
  1492. return rc4(e, code)
  1493. jsUrl = self.cm.ph.getSearchGroups(data, '"(http[^"]+?==\.js)"', 1, True)[0]
  1494. sts, data = self.cm.getPage(jsUrl, params)
  1495. printDBG(data)
  1496. code = self.cm.ph.getSearchGroups(data, 'code[ ]*?\=[ ]*?"([^"]+?)"')[0]
  1497. direct_link = self.cm.ph.getSearchGroups(data, 'direct_link[ ]*?\=[^"]*?"([^"]+?)"')[0]
  1498. videoUrl = link(direct_link, code)
  1499. if not videoUrl.strtswith("http"): return False
  1500. videoUrl = urlparser.decorateUrl(videoUrl, {'User-Agent':HTTP_HEADER['User-Agent'],'Referer': url})
  1501. return videoUrl
  1502. def parserPLAYEDTO(self, baseUrl):
  1503. if 'embed' in baseUrl:
  1504. url = baseUrl
  1505. else:
  1506. url = baseUrl.replace('org/', 'org/embed-').replace('to/', 'to/embed-') + '-640x360.html'
  1507. sts, data = self.cm.getPage(url)
  1508. if not sts: return False
  1509. if iframe:
  1510. url = self.cm.ph.getSearchGroups(data, '<iframe[^>]*?src="(http[^"]+?)"', 1, True)[0]
  1511. if url != '':
  1512. sts, data = self.cm.getPage(url, {'header':{'Referer':url, 'User-Agent':'Mozilla/5.0'}})
  1513. if not sts: return False
  1514. # get JS player script code from confirmation page
  1515. sts, tmpData = CParsingHelper.getDataBeetwenMarkers(data, ">eval(", '</script>', False)
  1516. if sts:
  1517. data = tmpData
  1518. tmpData = None
  1519. # unpack and decode params from JS player script code
  1520. data = unpackJSPlayerParams(data, VIDUPME_decryptPlayerParams, 0) #YOUWATCH_decryptPlayerParams == VIDUPME_decryptPlayerParams
  1521. # get direct link to file from params
  1522. data = re.search('file:[ ]*?"([^"]+?)"', data)
  1523. if data:
  1524. linkVideo = data.group(1)
  1525. printDBG('parserPLAYEDTO direct link: ' + linkVideo)
  1526. return linkVideo
  1527. return False
  1528. '''
  1529. def parserALLMYVIDEOS(self,url):
  1530. query_data = { 'url': url, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True }
  1531. link = self.cm.getURLRequestData(query_data)
  1532. ID = re.search('name="id" value="(.+?)">', link)
  1533. FNAME = re.search('name="fname" value="(.+?)">', link)
  1534. if ID and FNAME > 0:
  1535. time.sleep(105)
  1536. postdata = {'fname' : FNAME.group(1), 'method_free' : '1', 'id' : ID.group(1), 'x' : '82', 'y' : '13', 'op' : 'download1', 'referer' : url, 'usr_login' : '' }
  1537. query_data = { 'url': url, 'use_host': False, 'use_cookie': False, 'use_post': True, 'return_data': True }
  1538. link = self.cm.getURLRequestData(query_data, postdata)
  1539. match = re.compile('"file" : "(.+?)",').findall(link)
  1540. if len(match) > 0:
  1541. linkVideo = match[0]
  1542. print ('linkVideo ' + linkVideo)
  1543. return linkVideo
  1544. else:
  1545. return False
  1546. else:
  1547. return False
  1548. '''
  1549. def parserVIDEOMEGA(self, baseUrl):
  1550. baseUrl = strwithmeta(baseUrl)
  1551. Referer = baseUrl.meta.get('Referer', 'http://nocnyseans.pl/film/chemia-2015/15471')
  1552. video_id = self.cm.ph.getSearchGroups(baseUrl, 'https?://(?:www\.)?videomega\.tv/(?:iframe\.php|cdn\.php|view\.php)?\?ref=([A-Za-z0-9]+)')[0]
  1553. if video_id == '': video_id = self.cm.ph.getSearchGroups(baseUrl + '&', 'ref=([A-Za-z0-9]+)[^A-Za-z0-9]')[0]
  1554. COOKIE_FILE = GetCookieDir('videomegatv.cookie')
  1555. HTTP_HEADER= { 'User-Agent':'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/37.0.2062.120 Chrome/37.0.2062.120 Safari/537.36',
  1556. 'Accept-Encoding': 'gzip,deflate,sdch'} # (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10' }
  1557. params = {'header':HTTP_HEADER, 'cookiefile':COOKIE_FILE, 'use_cookie': True, 'save_cookie':True}
  1558. #if 'iframe' in baseUrl:
  1559. # iframe_url = 'http://videomega.tv/iframe.php?ref=%s' % (video_id)
  1560. # url = 'http://videomega.tv/iframe.php?ref=%s' % (video_id)
  1561. #else:
  1562. for i in range(2):
  1563. if i == 0:
  1564. iframe_url = 'http://videomega.tv/?ref=%s' % (video_id)
  1565. url = 'http://videomega.tv/cdn.php?ref=%s' % (video_id)
  1566. else:
  1567. url = 'http://videomega.tv/view.php?ref=%s&width=730&height=440&val=1' % (video_id)
  1568. iframe_url = url
  1569. HTTP_HEADER['Referer'] = Referer
  1570. sts, data = self.cm.getPage(url, params)
  1571. if not sts:
  1572. continue
  1573. if 'dmca ' in data:
  1574. DMCA = True
  1575. SetIPTVPlayerLastHostError("'Digital Millennium Copyright Act' detected.")
  1576. return False
  1577. else: DMCA = False
  1578. adUrl =self.cm.ph.getSearchGroups(data, '"([^"]+?/ad\.php[^"]+?)"')[0]
  1579. if adUrl.startswith("/"):
  1580. adUrl = 'http://videomega.tv' + adUrl
  1581. params = {'header':HTTP_HEADER, 'cookiefile':COOKIE_FILE, 'use_cookie': True, 'load_cookie':True, 'save_cookie':True}
  1582. HTTP_HEADER['Referer'] = url
  1583. if adUrl:
  1584. sts, tmp = self.cm.getPage(adUrl, params)
  1585. subTracksData = self.cm.ph.getAllItemsBeetwenMarkers(data, '<track ', '>', False, False)
  1586. subTracks = []
  1587. for track in subTracksData:
  1588. if 'kind="captions"' not in track: continue
  1589. subUrl = self.cm.ph.getSearchGroups(track, 'src="(http[^"]+?)"')[0]
  1590. subLang = self.cm.ph.getSearchGroups(track, 'srclang="([^"]+?)"')[0]
  1591. subLabel = self.cm.ph.getSearchGroups(track, 'label="([^"]+?)"')[0]
  1592. subTracks.append({'title':subLabel + '_' + subLang, 'url':subUrl, 'lang':subLang, 'format':'srt'})
  1593. linksTab = []
  1594. fakeLinkVideo = self.cm.ph.getSearchGroups(data, 'src="([^"]+?)"[^>]+?type="video')[0]
  1595. # get JS player script code from confirmation page
  1596. sts, data = CParsingHelper.getDataBeetwenMarkers(data, "eval(", '</script>')
  1597. if not sts: continue
  1598. printDBG('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
  1599. printDBG(data)
  1600. printDBG('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
  1601. # unpack and decode params from JS player script code
  1602. decrypted = False
  1603. for decryptor in [SAWLIVETV_decryptPlayerParams, VIDUPME_decryptPlayerParams]:
  1604. try:
  1605. data = unpackJSPlayerParams(data, decryptor, 0)
  1606. if len(data):
  1607. decrypted = True
  1608. break
  1609. except:
  1610. continue
  1611. if not decrypted: continue
  1612. linkVideo = self.cm.ph.getSearchGroups(data, '"(http[^"]+?\.mp4\?[^"]+?)"')[0]
  1613. if fakeLinkVideo == linkVideo:
  1614. SetIPTVPlayerLastHostError(_("Videomega has blocked your IP for some time.\nPlease retry this link after some time."))
  1615. if i == 0: time.sleep(3)
  1616. continue
  1617. #printDBG('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
  1618. #printDBG("DMCA [%r]" % DMCA)
  1619. if linkVideo.startswith('http'):
  1620. linksTab.append({'name': 'videomega_2', 'url':urlparser.decorateUrl(linkVideo, {'external_sub_tracks':subTracks, "iptv_wget_continue":True, "iptv_wget_timeout":10, "Orgin": "http://videomega.tv/", 'Referer': url, 'User-Agent':HTTP_HEADER['User-Agent'], 'iptv_buffering':'required'})})
  1621. #"Cookie": "__cfduid=1", "Range": "bytes=0-",
  1622. return linksTab
  1623. def parserVIDTO(self, baseUrl):
  1624. printDBG('parserVIDTO baseUrl[%s]' % baseUrl)
  1625. HTTP_HEADER= { 'User-Agent':"Mozilla/5.0", 'Referer':baseUrl }
  1626. if 'embed' not in baseUrl:
  1627. video_id = self.cm.ph.getSearchGroups(baseUrl+'/', '/([A-Za-z0-9]{12})[\./]')[0]
  1628. url = 'http://vidto.me/embed-{0}-640x360.html'.format(video_id)
  1629. else:
  1630. url = baseUrl
  1631. params = {'header' : HTTP_HEADER}
  1632. sts, data = self.cm.getPage(url, params)
  1633. # get JS player script code from confirmation page
  1634. sts, data = CParsingHelper.getDataBeetwenMarkers(data, ">eval(", '</script>')
  1635. if not sts: return False
  1636. # unpack and decode params from JS player script code
  1637. data = unpackJSPlayerParams(data, VIDUPME_decryptPlayerParams)
  1638. return self._findLinks(data, 'vidto.me', m1='hd', m2=']')
  1639. def parserVIDSTREAM(self,url):
  1640. query_data = { 'url': url, 'use_host': False, 'use_cookie': False, 'use_post': False, 'return_data': True }
  1641. link = self.cm.getURLRequestData(query_data)
  1642. ID = re.search('name="id" value="(.+?)">', link)
  1643. FNAME = re.search('name="fname" value="(.+?)">', link)
  1644. HASH = re.search('name="hash" value="(.+?)">', link)
  1645. if ID and FNAME and HASH > 0:
  1646. time.sleep(55)
  1647. postdata = {'fname' : FNAME.group(1), 'id' : ID.group(1), 'hash' : HASH.group(1), 'imhuman' : 'Proceed to video', 'op' : 'download1', 'referer' : url, 'usr_login' : '' }
  1648. query_data = { 'url': url, 'use_host': False, 'use_cookie': False, 'use_post': True, 'return_data': True }
  1649. link = self.cm.getURLRequestData(query_data, postdata)
  1650. match = re.compile('file: "(.+?)",').findall(link)
  1651. if len(match) > 0:
  1652. linkVideo = match[0]
  1653. printDBG ('linkVideo :' + linkVideo)
  1654. return linkVideo
  1655. else:
  1656. return False
  1657. else:
  1658. return False
  1659. def parserYANDEX(self, url):
  1660. #http://www.kreskoweczki.pl/kreskowka/71428/nawiedzeni_4-haunted-kids/
  1661. #http://seositer.com/player10-loader.swf?login=eriica&storage_directory=xeacxjweav.5822/&is-hq=false
  1662. #player10-loader.swf?login=eriica&storage_directory=xeacxjweav.5822/&is-hq=true
  1663. DEFAULT_FORMAT = 'mpeg4_low'
  1664. # authorization
  1665. authData = ''
  1666. urlElems = urlparse(url)
  1667. urlParams = parse_qs(urlElems.query)
  1668. if 0 < len(urlParams.get('file', [])):
  1669. return urlParams['file'][0]
  1670. elif 0 < len(urlParams.get('login', [])) and 0 < len(urlParams.get('storage_directory', [])):
  1671. authData = urlParams['login'][0] + '/' + urlParams['storage_directory'][0]
  1672. elif 'vkid=' in url:
  1673. sts, data = self.cm.getPage(url)
  1674. if not sts: return False
  1675. data = self.cm.ph.getSearchGroups(data, '<iframe[^>]+?src="([^"]+?)"')[0]
  1676. return urlparser().getVideoLink(data, True)
  1677. else:
  1678. # last chance
  1679. r = re.compile('iframe/(.+?)\?|$').findall(url)
  1680. if 0 <= len(r): return False
  1681. authData = r[0]
  1682. # consts
  1683. playerUrlPrefix = "http://flv.video.yandex.ru/"
  1684. tokenUrlPrefix = "http://static.video.yandex.ru/get-token/"
  1685. serviceHostUrl = "http://video.yandex.ru/"
  1686. storageHostUrl = "http://static.video.yandex.ru/"
  1687. clipStorageHostUrl = "http://streaming.video.yandex.ru/"
  1688. nameSpace = "get"
  1689. FORMATS_MAP = {}
  1690. FORMATS_MAP["flv_low"] = "0.flv"
  1691. FORMATS_MAP["mpeg4_low"] = "m450x334.mp4"
  1692. FORMATS_MAP["mpeg4_med"] = "medium.mp4"
  1693. FORMATS_MAP["mpeg4_hd_720p"] = "m1280x720.mp4"
  1694. FORMATS_MAP["flv_h264_low"] = "m450x334.flv"
  1695. FORMATS_MAP["flv_h264_med"] = "medium.flv"
  1696. FORMATS_MAP["flv_h264_hd_720p"] = "m1FLV_SAME_QUALITY280x720.flv"
  1697. FORMATS_MAP["flv_same_quality"] = "sq-medium.flv"
  1698. # get all video formats info
  1699. # http://static.video.yandex.ru/get/eriica/xeacxjweav.5822//0h.xml?nc=0.9776535825803876
  1700. url = storageHostUrl + nameSpace + "/" + authData + "/0h.xml?nc=" + str(random())
  1701. sts, data = self.cm.getPage(url)
  1702. if not sts: return False
  1703. try:
  1704. formatsTab = []
  1705. defaultItem = None
  1706. for videoFormat in cElementTree.fromstring(data).find("formats_available").getiterator():
  1707. fileName = FORMATS_MAP.get(videoFormat.tag, '')
  1708. if '' != fileName:
  1709. bitrate = int(videoFormat.get('bitrate', 0))
  1710. formatItem = { 'bitrate': bitrate, 'file':fileName, 'ext':fileName[-3:] }
  1711. if DEFAULT_FORMAT == videoFormat.tag:
  1712. defaultItem = formatItem
  1713. else:
  1714. formatsTab.append(formatItem)
  1715. if None != defaultItem: formatsTab.insert(0, defaultItem)
  1716. if 0 == len(formatsTab): return False
  1717. # get token
  1718. token = tokenUrlPrefix + authData + "?nc=" + str(random())
  1719. sts, token = self.cm.getPage(token)
  1720. sts, token = CParsingHelper.getDataBeetwenMarkers(token, "<token>", '</token>', False)
  1721. if not sts:
  1722. printDBG("parserYANDEX - get token problem")
  1723. return False
  1724. movieUrls = []
  1725. for item in formatsTab:
  1726. # get location
  1727. location = clipStorageHostUrl + 'get-location/' + authData + '/' + item['file'] + '?token=' + token + '&ref=video.yandex.ru'
  1728. sts, location = self.cm.getPage(location)
  1729. sts, location = CParsingHelper.getDataBeetwenMarkers(location, "<video-location>", '</video-location>', False)
  1730. if sts: movieUrls.append({ 'name': 'yandex.ru: ' + item['ext'] + ' bitrate: ' + str(item['bitrate']), 'url':location.replace('&amp;', '&') })
  1731. else: printDBG("parserYANDEX - get location problem")
  1732. return movieUrls
  1733. except:
  1734. printDBG("parserYANDEX - formats xml problem")
  1735. printExc()
  1736. return False
  1737. def parserANIMESHINDEN(self, url):
  1738. query_data = { 'url': url, 'return_data': False }
  1739. response = self.cm.getURLRequestData(query_data)
  1740. redirectUrl = response.geturl()
  1741. response.close()
  1742. redirectUrl = redirectUrl.replace('https', 'http')
  1743. return redirectUrl
  1744. def parserRUTUBE(self, url):
  1745. if '//rutube.ru/video/embed' in url or '//rutube.ru/play/embed/' in url:
  1746. sts, data = self.cm.getPage(url)
  1747. if not sts: return False
  1748. data = re.search('href="([^"]+?)"', data)
  1749. if not data: return False
  1750. url = data.group(1)
  1751. videoID = ''
  1752. url += '/'
  1753. # get videoID/hash
  1754. match = re.search('video\.rutube\.ru/(\w+?)/', url)
  1755. if match:
  1756. videoID = match.group(1)
  1757. else:
  1758. match = re.search('/video/(\w+?)/', url)
  1759. if match:
  1760. videoID = match.group(1)
  1761. else:
  1762. match = re.search('hash=([^/]+?)/', url)
  1763. if match:
  1764. videoID = match.group(1)
  1765. if '' != videoID:
  1766. printDBG('parserRUTUBE: videoID[%s]' % videoID)
  1767. # get videoInfo:
  1768. #vidInfoUrl = 'http://rutube.ru/api/play/trackinfo/%s/?format=json' % videoID
  1769. vidInfoUrl = 'http://rutube.ru/api/play/options/%s/?format=json&referer=&no_404=true&sqr4374_compat=1' % videoID
  1770. query_data = { 'url': vidInfoUrl, 'return_data': True }
  1771. try:
  1772. videoInfo = self.cm.getURLRequestData(query_data)
  1773. except:
  1774. printDBG('parserRUTUBE problem with getting video info page')
  1775. return []
  1776. printDBG('---------------------------------------------------------')
  1777. printDBG(videoInfo)
  1778. printDBG('---------------------------------------------------------')
  1779. # "m3u8": "http://bl.rutube.ru/ae8621ff85153a30c398746ed8d6cc03.m3u8"
  1780. # "f4m": "http://bl.rutube.ru/ae8621ff85153a30c398746ed8d6cc03.f4m"
  1781. videoUrls = []
  1782. match = re.search('"m3u8":[ ]*?"(http://bl\.rutube\.ru/.+?)"', videoInfo)
  1783. if match:
  1784. printDBG('parserRUTUBE m3u8 link[%s]' % match.group(1))
  1785. retTab = getDirectM3U8Playlist(match.group(1))
  1786. videoUrls.extend(retTab)
  1787. else:
  1788. printDBG('parserRUTUBE there is no m3u8 link in videoInfo:')
  1789. printDBG('---------------------------------------------------------')
  1790. printDBG(videoInfo)
  1791. printDBG('---------------------------------------------------------')
  1792. match = re.search('"default":[ ]*?"(http://[^"]+?f4m[^"]*?)"', videoInfo)
  1793. if match:
  1794. printDBG('parserRUTUBE f4m link[%s]' % match.group(1))
  1795. retTab = getF4MLinksWithMeta(match.group(1))
  1796. videoUrls.extend(retTab)
  1797. return videoUrls
  1798. else:
  1799. printDBG('parserRUTUBE ERROR cannot find videoID in link[%s]' % url)
  1800. return []
  1801. def parserYOUTUBE(self, url):
  1802. if None != self.getYTParser():
  1803. try:
  1804. formats = config.plugins.iptvplayer.ytformat.value
  1805. bitrate = config.plugins.iptvplayer.ytDefaultformat.value
  1806. dash = config.plugins.iptvplayer.ytShowDash.value
  1807. except:
  1808. printDBG("parserYOUTUBE default ytformat or ytDefaultformat not available here")
  1809. formats = "mp4"
  1810. bitrate = "360"
  1811. dash = False
  1812. tmpTab, dashTab = self.getYTParser().getDirectLinks(url, formats, dash, dashSepareteList = True)
  1813. # move default URL to the TOP of list
  1814. if 1 < len(tmpTab):
  1815. def __getLinkQuality( itemLink ):
  1816. tab = itemLink['format'].split('x')
  1817. return int(tab[0])
  1818. # get default item
  1819. defItem = CSelOneLink(tmpTab, __getLinkQuality, int(bitrate)).getOneLink()[0]
  1820. # remove default item
  1821. tmpTab[:] = [x for x in tmpTab if x['url'] != defItem['url']]
  1822. # add default item at top
  1823. tmpTab.insert(0, defItem)
  1824. videoUrls = []
  1825. for item in tmpTab:
  1826. url = strwithmeta(item['url'], {'youtube_id':item.get('id', '')})
  1827. videoUrls.append({ 'name': 'YouTube: ' + item['format'] + '\t' + item['ext'] , 'url':url})
  1828. for item in dashTab:
  1829. url = strwithmeta(item['url'], {'youtube_id':item.get('id', '')})
  1830. videoUrls.append({'name': _("[For download only] ") + item['format'] + ' | dash', 'url':url})
  1831. return videoUrls
  1832. return False
  1833. def parserTINYMOV(self, url):
  1834. printDBG('parserTINYMOV url[%s]' % url)
  1835. sts, data = self.cm.getPage(url)
  1836. if sts:
  1837. match = re.search("url: '([^']+?.mp4|[^']+?.flv)',", data)
  1838. if match:
  1839. linkVideo = match.group(1)
  1840. printDBG ('parserTINYMOV linkVideo :' + linkVideo)
  1841. return linkVideo
  1842. return False
  1843. def parserTOPUPLOAD(self, url):
  1844. url = url.replace('topupload.tv', 'maxupload.tv')
  1845. HTTP_HEADER = {'Referer':url}
  1846. post_data = {'ok':'yes', 'confirm':'Close+Ad+and+Watch+as+Free+User', 'submited':'true'}
  1847. sts, data = self.cm.getPage(url=url, addParams={'header':HTTP_HEADER}, post_data = post_data)
  1848. if sts:
  1849. posibility = ["'file': '([^']+?)'", "file: '([^']+?)'", "'url': '(http[^']+?)'", "url: '(http[^']+?)'"]
  1850. for posibe in posibility:
  1851. match = re.search(posibe, data)
  1852. if match:
  1853. try:
  1854. header = {'Referer':'http://www.maxupload.tv/media/swf/player/player.swf'}
  1855. query_data = { 'url': match.group(1), 'return_data': False, 'header':header }
  1856. response = self.cm.getURLRequestData(query_data)
  1857. redirectUrl = response.geturl()
  1858. response.close()
  1859. return redirectUrl
  1860. except:
  1861. printExc()
  1862. else:
  1863. printDBG('parserTOPUPLOAD direct link not found in return data')
  1864. else:
  1865. printDBG('parserTOPUPLOAD error when getting page')
  1866. return False
  1867. def parserLIVELEAK(self, baseUrl):
  1868. printDBG('parserLIVELEAK baseUrl[%s]' % baseUrl)
  1869. urlTab = []
  1870. sts, data = self.cm.getPage(baseUrl)
  1871. if sts:
  1872. file_url = urllib.unquote(self.cm.ph.getSearchGroups(data, 'file_url=(http[^&]+?)&')[0])
  1873. hd_file_url = urllib.unquote(self.cm.ph.getSearchGroups(data, 'hd_file_url=(http[^&]+?)&')[0])
  1874. if '' != file_url:
  1875. urlTab.append({'name':'liveleak.com SD', 'url':file_url})
  1876. if '' != hd_file_url:
  1877. urlTab.append({'name':'liveleak.com HD', 'url':hd_file_url})
  1878. printDBG(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [%s]" % urlTab)
  1879. if 0 == len(urlTab):
  1880. url = self.cm.ph.getSearchGroups(data, '<iframe[^>]+?src="(http[^"]+?youtube[^"]+?)"')[0]
  1881. if '' != url:
  1882. urlTab = self.parserYOUTUBE(url)
  1883. return urlTab
  1884. def parserVIDUPME(self, baseUrl):
  1885. printDBG("parserVIDUPME baseUrl[%r]" % baseUrl)
  1886. # example video: http://beta.vidup.me/embed-p1ko9zqn5e4h-640x360.html
  1887. def _findLinks(data):
  1888. return self._findLinks(data, 'beta.vidup.me', m1='setup(', m2='image:')
  1889. return self._parserUNIVERSAL_A(baseUrl, 'http://beta.vidup.me/embed-{0}-640x360.html', _findLinks)
  1890. def parseMOSHAHDANET(self, baseUrl):
  1891. printDBG("parseMOSHAHDANET baseUrl[%r]" % baseUrl)
  1892. sts, data = self.cm.getPage(baseUrl)
  1893. if not sts: return False
  1894. data = self.cm.ph.getDataBeetwenMarkers(data, 'method="POST"', '</Form>', False)[1]
  1895. post_data = dict(re.findall(r'<input[^>]*name="([^"]*)"[^>]*value="([^"]*)"[^>]*>', data))
  1896. HTTP_HEADER= { 'User-Agent':"Mozilla/5.0", 'Referer':baseUrl }
  1897. try:
  1898. sleep_time = int(self.cm.ph.getSearchGroups(data, '<span id="cxc">([0-9])</span>')[0])
  1899. time.sleep(sleep_time)
  1900. except:
  1901. printExc()
  1902. sts, data = self.cm.getPage(baseUrl, {'header' : HTTP_HEADER}, post_data)
  1903. return self._findLinks(data, 'moshahda.net')
  1904. def parseSTREAMMOE(self, baseUrl):
  1905. printDBG("parseSTREAMMOE baseUrl[%r]" % baseUrl)
  1906. HTTP_HEADER= { 'User-Agent':"Mozilla/5.0", 'Referer':baseUrl }
  1907. url = baseUrl
  1908. sts, data = self.cm.getPage(url, {'header':HTTP_HEADER})
  1909. if not sts:
  1910. cmd = DMHelper.getBaseWgetCmd(HTTP_HEADER) + url + ' -O - 2> /dev/null'
  1911. data = iptv_execute()( cmd )
  1912. if not data['sts'] or 0 != data['code']: return False
  1913. data = data['data']
  1914. data = re.sub('''atob\(["']([^"^']+?)['"]\)''', lambda m: base64.b64decode(m.group(1)), data)
  1915. printDBG(data)
  1916. tab = self._findLinks(data, 'stream.moe', linkMarker=r'''['"]?url['"]?[ ]*:[ ]*['"](http[^"^']+(?:\.mp4|\.flv)[^"^']*)['"][,}]''', m1='clip:')
  1917. if len(tab) == 0:
  1918. data = self.cm.ph.getAllItemsBeetwenMarkers(data, '<source', '>', False, False)
  1919. for item in data:
  1920. if 'video/mp4' in item:
  1921. url = self.cm.ph.getSearchGroups(item, '''src=['"]([^"^']+?)['"]''')[0]
  1922. tab.append({'name':'stream.moe', 'url':url})
  1923. return tab
  1924. def parseCASTFLASHPW(self, baseUrl):
  1925. printDBG("parseCASTFLASHPW baseUrl[%r]" % baseUrl)
  1926. baseUrl = strwithmeta(baseUrl)
  1927. Referer = baseUrl.meta.get('Referer', baseUrl)
  1928. aesKey = baseUrl.meta.get('aes_key', '')
  1929. def getUtf8Str(st):
  1930. idx = 0
  1931. st2 = ''
  1932. while idx < len(st):
  1933. st2 += '\\u0' + st[idx:idx + 3]
  1934. idx += 3
  1935. return st2.decode('unicode-escape').encode('UTF-8')
  1936. def cryptoJS_AES_decrypt(encrypted, password, salt):
  1937. def derive_key_and_iv(password, salt, key_length, iv_length):
  1938. d = d_i = ''
  1939. while len(d) < key_length + iv_length:
  1940. d_i = md5(d_i + password + salt).digest()
  1941. d += d_i
  1942. return d[:key_length], d[key_length:key_length+iv_length]
  1943. bs = 16
  1944. key, iv = derive_key_and_iv(password, salt, 32, 16)
  1945. cipher = AES_CBC(key=key, keySize=32)
  1946. return cipher.decrypt(encrypted, iv)
  1947. for agent in ['Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10']: #, 'Mozilla/5.0']:
  1948. HTTP_HEADER= { 'User-Agent':agent, 'Referer':Referer }
  1949. COOKIE_FILE = GetCookieDir('castflashpw.cookie')
  1950. params = {'header':HTTP_HEADER, 'cookiefile':COOKIE_FILE, 'use_cookie': True, 'load_cookie':False, 'save_cookie':True}
  1951. url = baseUrl
  1952. sts, data = self.cm.getPage(url, params)
  1953. if not sts: return False
  1954. printDBG(data)
  1955. post_data = self.cm.ph.getDataBeetwenMarkers(data, '<form ', '</form>', withMarkers=False, caseSensitive=False)[1]
  1956. post_data = dict(re.findall(r'<input[^>]*name="([^"]*)"[^>]*value="([^"]*)"[^>]*>', post_data))
  1957. params['header']['Referer'] = url
  1958. params['load_cookie'] = True
  1959. url = self.cm.ph.getSearchGroups(data, '''attr\([^<]*?['"]action["'][^<]*?\,[^<]*?["'](http[^'^"]+?)['"]''')[0]
  1960. printDBG(url)
  1961. sts, data = self.cm.getPage(url, params, post_data)
  1962. if not sts: return False
  1963. marker = '__showH5'
  1964. if marker in data:
  1965. linksData = []
  1966. tmp = self.cm.ph.getDataBeetwenMarkers(data, marker + '(', ')', False)[1].split(',')
  1967. for t in tmp:
  1968. linksData.append(t.replace('"', '').strip())
  1969. printDBG(linksData)
  1970. linkData = base64.b64decode(linksData[2])
  1971. linkData = byteify(json.loads(linkData))
  1972. ciphertext = base64.b64decode(linkData['ct'])
  1973. iv = a2b_hex(linkData['iv'])
  1974. salt = a2b_hex(linkData['s'])
  1975. playerUrl = cryptoJS_AES_decrypt(ciphertext, aesKey, salt)
  1976. playerUrl = byteify(json.loads(playerUrl))
  1977. if playerUrl.startswith('#') and 3 < len(playerUrl):
  1978. playerUrl = getUtf8Str(playerUrl[1:])
  1979. printDBG("[[[[[[[[[[[[[[[[[[[[[[%r]" % playerUrl)
  1980. if playerUrl.startswith('http'):
  1981. COOKIE_FILE_M3U8 = GetCookieDir('m3u8.cookie')
  1982. params = {'cookiefile':COOKIE_FILE_M3U8, 'use_cookie': True, 'load_cookie':False, 'save_cookie':True}
  1983. playerUrl = urlparser.decorateUrl(playerUrl, {'iptv_livestream':True, 'Referer':'http://h5.adshell.net/flash', 'User-Agent':HTTP_HEADER['User-Agent']})
  1984. urlsTab = getDirectM3U8Playlist(playerUrl, cookieParams=params)
  1985. try:
  1986. PHPSESSID = self.cm.getCookieItem(COOKIE_FILE_M3U8, 'PHPSESSID')
  1987. newUrlsTab = []
  1988. for item in urlsTab:
  1989. item['url'].meta['Cookie'] = 'PHPSESSID=%s' % PHPSESSID
  1990. newUrlsTab.append(item)
  1991. return newUrlsTab
  1992. except:
  1993. printExc()
  1994. return urlsTab
  1995. return False
  1996. def parserTRILULILU(self, baseUrl):
  1997. def getTrack(userid, hash):
  1998. hashLen = len(hash) / 2
  1999. mixedStr = (hash[0:hashLen] + userid) + hash[hashLen:len(hash)]
  2000. md5Obj = MD5()
  2001. hashTab = md5Obj(mixedStr)
  2002. return hexlify(hashTab)
  2003. match = re.search("embed\.trilulilu\.ro/video/([^/]+?)/([^.]+?)\.swf", baseUrl)
  2004. data = None
  2005. if not match:
  2006. sts, data = self.cm.getPage(baseUrl)
  2007. if not sts: return False
  2008. match = re.search('userid=([^"^<^>^&]+?)&hash=([^"^<^>^&]+?)&', data)
  2009. if match:
  2010. userid = match.group(1)
  2011. hash = match.group(2)
  2012. refererUrl = "http://static.trilulilu.ro/flash/player/videoplayer2011.swf?userid=%s&hash=%s&referer=" % (userid, hash)
  2013. fileUrl = "http://embed.trilulilu.ro/flv/" + userid + "/" + hash + "?t=" + getTrack(userid, hash) + "&referer=" + urllib.quote_plus( base64.b64encode(refererUrl) ) + "&format=mp4-360p"
  2014. return fileUrl
  2015. # new way to get video
  2016. if sts:
  2017. url = self.cm.ph.getSearchGroups(data, 'id="link" href="(http[^"]+?)"')[0]
  2018. if '' != url:
  2019. HTTP_HEADER = dict(self.HTTP_HEADER)
  2020. HTTP_HEADER['Referer'] = baseUrl
  2021. sts, data = self.cm.getPage(url, {'header' : HTTP_HEADER})
  2022. data = self.cm.ph.getSearchGroups(data, """["']*video["']*:[ ]*["']([^"']+?)["']""")[0]
  2023. if '' != data:
  2024. if data.startswith('//'):
  2025. data = 'http:' + data
  2026. return data
  2027. return False
  2028. def parserVIDEA(self, url):
  2029. sts, data = self.cm.getPage(url)
  2030. if not sts: return False
  2031. r = re.compile('v=(.+?)&eventHandler').findall(data)
  2032. sts, data = self.cm.getPage('http://videa.hu/flvplayer_get_video_xml.php?v='+r[0])
  2033. if not sts: return False
  2034. r2 = re.compile('video_url="(.+?)"').findall(data)
  2035. return r2[0]
  2036. def parserALIEZ(self, url):
  2037. sts, data = self.cm.getPage(url)
  2038. if not sts: return False
  2039. r = re.compile("file:.+?'(.+?)'").findall(data)
  2040. return r[0]
  2041. def parserVIDEOMAIL(self, url):
  2042. printDBG("parserVIDEOMAIL baseUrl[%s]" % url)
  2043. #http://api.video.mail.ru/videos/embed/mail/etaszto/_myvideo/852.html
  2044. #http://my.mail.ru/video/mail/etaszto/_myvideo/852.html#video=/mail/etaszto/_myvideo/852
  2045. COOKIEFILE = self.COOKIE_PATH + "video.mail.ru.cookie"
  2046. movieUrls = []
  2047. try:
  2048. sts, data = self.cm.getPage(url, {'cookiefile': COOKIEFILE, 'use_cookie': True, 'save_cookie': True, 'load_cookie': False})
  2049. if 'This video is only available on Mail.Ru' in data:
  2050. tmpUrl = self.cm.ph.getSearchGroups(data, 'href="([^"]+?)"')[0]
  2051. sts, data = self.cm.getPage(tmpUrl)
  2052. metadataUrl = self.cm.ph.getSearchGroups(data, """["']*metadataUrl["']*[ ]*:[ ]*["'](http[^"']+?\.json[^"']*?)["']""")[0]
  2053. if '' == metadataUrl:
  2054. tmp = self.cm.ph.getSearchGroups(data, """["']*metadataUrl["']*[ ]*:[ ]*["'][^0-9]*?([0-9]{19})[^0-9]*?["']""")[0]
  2055. if '' == tmp:
  2056. tmp = self.cm.ph.getSearchGroups(data, '<link[^>]*?rel="image_src"[^>]*?href="([^"]+?)"')[0]
  2057. if '' == tmp: tmp = self.cm.ph.getSearchGroups(data, '<link[^>]*?href="([^"]+?)"[^>]*?rel="image_src"[^>]*?')[0]
  2058. tmp = self.cm.ph.getSearchGroups(urllib.unquote(tmp), '[^0-9]([0-9]{19})[^0-9]')[0]
  2059. metadataUrl = 'http://videoapi.my.mail.ru/videos/{0}.json?ver=0.2.102'.format(tmp)
  2060. sts, data = self.cm.getPage(metadataUrl, {'cookiefile': COOKIEFILE, 'use_cookie': True, 'save_cookie': True, 'load_cookie': True})
  2061. video_key = self.cm.getCookieItem(COOKIEFILE,'video_key')
  2062. if '' != video_key:
  2063. data = json.loads(data)['videos']
  2064. for item in data:
  2065. videoUrl = strwithmeta(item['url'].encode('utf-8'), {'Cookie':"video_key=%s" % video_key, 'iptv_buffering':'required'})
  2066. videoName = 'mail.ru: %s' % item['key'].encode('utf-8')
  2067. movieUrls.append({ 'name': videoName, 'url': videoUrl})
  2068. except:
  2069. printExc()
  2070. # Try old code extractor
  2071. if 0 == len(movieUrls):
  2072. idx = url.find(".html")
  2073. if 1 > idx: return False
  2074. authData = url[:idx].split('/')
  2075. url = 'http://api.video.mail.ru/videos/' + authData[-4] + '/' + authData[-3] + '/' + authData[-2] + '/' + authData[-1] + '.json'
  2076. sts, data = self.cm.getPage(url, {'cookiefile': COOKIEFILE, 'use_cookie': True, 'save_cookie': True, 'load_cookie': False})
  2077. if not sts: return False
  2078. video_key = self.cm.getCookieItem(COOKIEFILE,'video_key')
  2079. if '' == video_key: return False
  2080. data = re.search('"videos":{([^}]+?)}', data)
  2081. if not data: return False
  2082. formats = ['sd', 'hd']
  2083. for item in formats:
  2084. url = re.search('"%s":"([^"]+?)"' % item, data.group(1))
  2085. if url:
  2086. movieUrls.append({ 'name': 'mail.ru: %s' % item, 'url':url.group(1) + '|Cookie="video_key=' + video_key + '"' })
  2087. return movieUrls
  2088. def parserWRZUTA(self, url):
  2089. movieUrls = []
  2090. # start algo from https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/wrzuta.py
  2091. _VALID_URL = r'https?://(?P<uploader>[0-9a-zA-Z]+)\.wrzuta\.pl/(?P<typ>film|audio)/(?P<id>[0-9a-zA-Z]+)'
  2092. try:
  2093. while True:
  2094. mobj = re.match(_VALID_URL, url)
  2095. video_id = mobj.group('id')
  2096. typ = mobj.group('typ')
  2097. uploader = mobj.group('uploader')
  2098. #sts, data = self.cm.getPage(url)
  2099. #if not sts: break
  2100. quality = {'SD':240, 'MQ':360, 'HQ':480, 'HD':720}
  2101. audio_table = {'flv': 'mp3', 'webm': 'ogg', '???': 'mp3'}
  2102. sts, data = self.cm.getPage('http://www.wrzuta.pl/npp/embed/%s/%s' % (uploader, video_id))
  2103. if not sts: break
  2104. data = byteify( json.loads(data) )
  2105. for media in data['url']:
  2106. fmt = media['type'].split('@')[0]
  2107. if typ == 'audio':
  2108. ext = audio_table.get(fmt, fmt)
  2109. else:
  2110. ext = fmt
  2111. if fmt in ['webm']: continue
  2112. movieUrls.append({'name': 'wrzuta.pl: ' + str(quality.get(media['quality'], 0)) + 'p', 'url':media['url']})
  2113. break;
  2114. except:
  2115. printExc()
  2116. # end algo
  2117. if len(movieUrls): return movieUrls
  2118. def getShardUserFromKey(key):
  2119. tab = ["w24", "w101", "w70", "w60", "w2", "w14", "w131", "w121", "w50", "w40", "w44", "w450", "w90", "w80", "w30", "w20", "w25", "w100", "w71", "w61", "w1", "w15", "w130", "w120", "w51", "w41", "w45", "w451", "w91", "w81", "w31", "w21"]
  2120. abc = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
  2121. usr_idx = 0
  2122. for i in range(11):
  2123. tmp = key[i]
  2124. usr_idx = (usr_idx * len(abc))
  2125. usr_idx = (usr_idx + abc.find(tmp))
  2126. usr_idx = (usr_idx & 0xFFFF)
  2127. return tab[usr_idx]
  2128. def getFileData(login, key, flagaXml, host, site, pltype):
  2129. url = "http://" + login + "." + host + "/xml/" + flagaXml + "/" + key + "/" + site + "/" + pltype + "/" + str(int(random() * 1000000 + 1))
  2130. sts, data = self.cm.getPage(url)
  2131. return data
  2132. urlElems = urlparse(url)
  2133. urlParams = parse_qs(urlElems.query)
  2134. site = urlParams.get('site', ["wrzuta.pl"])[0]
  2135. host = urlParams.get('host', ["wrzuta.pl"])[0]
  2136. key = urlParams.get('key', [None])[0]
  2137. login = urlParams.get('login', [None])[0]
  2138. language = urlParams.get('login', ["pl"])[0]
  2139. boolTab = ["yes", "true", "t", "1"]
  2140. embeded = urlParams.get('embeded', ["false"])[0].lower() in boolTab
  2141. inskin = urlParams.get('inskin', ["false"])[0].lower() in boolTab
  2142. if None == key: return False
  2143. if None == login: login = getShardUserFromKey(key)
  2144. if embeded: pltype = "eb"
  2145. elif inskin: pltype = "is"
  2146. else: pltype = "sa"
  2147. data = getFileData(login, key, "kontent", host, site, pltype)
  2148. formatsTab = [{'bitrate':360, 'file':'fileMQId_h5'},\
  2149. {'bitrate':480, 'file':'fileHQId_h5'},\
  2150. {'bitrate':720, 'file':'fileHDId_h5'},\
  2151. {'bitrate':240, 'file':'fileId_h5'}]
  2152. for item in formatsTab:
  2153. sts, url = CParsingHelper.getDataBeetwenMarkers(data, "<%s>" % item['file'], '</%s>' % item['file'], False)
  2154. url = url.replace('<![CDATA[', '').replace(']]>', '')
  2155. if sts: movieUrls.append({'name': 'wrzuta.pl: ' + str(item['bitrate']) + 'p', 'url':url.strip() + '/0'})
  2156. return movieUrls
  2157. def parserGOLDVODTV(self, baseUrl):
  2158. COOKIE_FILE = GetCookieDir('goldvodtv.cookie')
  2159. HTTP_HEADER = { 'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3 Gecko/2008092417 Firefox/3.0.3' }
  2160. SWF_URL = 'http://p.jwpcdn.com/6/9/jwplayer.flash.swf'
  2161. url = strwithmeta(baseUrl)
  2162. baseParams = url.meta.get('params', {})
  2163. params = {'header':HTTP_HEADER, 'cookiefile':COOKIE_FILE, 'use_cookie': True, 'save_cookie':True}
  2164. params.update(baseParams)
  2165. sts, data = self.cm.getPage( baseUrl, params)
  2166. msg = 'Dostęp wyłącznie dla użytkowników z kontem premium.'
  2167. if msg in data:
  2168. SetIPTVPlayerLastHostError(msg)
  2169. urlTab = []
  2170. qualities = []
  2171. tmp = self.cm.ph.getDataBeetwenMarkers(data, "box_quality", "</div>", False)[1]
  2172. tmp = re.compile('''<a[^>]+?href=['"]([^'^"]+?)['"][^>]*?>([^<]+?)</a>''').findall(tmp)
  2173. for item in tmp:
  2174. qualities.append({'title':item[1], 'url':baseUrl+item[0]})
  2175. if len(qualities):
  2176. data2 = None
  2177. else:
  2178. data2 = data
  2179. qualities.append({'title':'default', 'url':baseUrl})
  2180. for item in qualities:
  2181. if data2 == None:
  2182. sts, data2 = self.cm.getPage( item['url'], params)
  2183. if not sts:
  2184. data2 = None
  2185. continue
  2186. data2 = self.cm.ph.getDataBeetwenMarkers(data2, '.setup(', '}', False)[1]
  2187. #printDBG(data2)
  2188. rtmpUrls = re.compile('''(rtmp[^"^']+?)["'&]''').findall(data2)
  2189. for idx in range(len(rtmpUrls)):
  2190. rtmpUrl = urllib.unquote(rtmpUrls[idx])
  2191. if len(rtmpUrl):
  2192. rtmpUrl = rtmpUrl + ' swfUrl=%s live=1 pageUrl=%s' % (SWF_URL, baseUrl)
  2193. urlTab.append({'name':'{0}. '.format(idx+1) + item['title'], 'url':rtmpUrl})
  2194. data2 = None
  2195. if len(urlTab):
  2196. printDBG(urlTab)
  2197. return urlTab
  2198. # get connector link
  2199. data = self.cm.ph.getSearchGroups(data, "'(http://goldvod.tv/tv-connector/[^']+?\.smil[^']*?)'")[0]
  2200. params['load_cookie'] = True
  2201. params['header']['Referer'] = SWF_URL
  2202. # get stream link
  2203. sts, data = self.cm.getPage(data, params)
  2204. if sts:
  2205. base = self.cm.ph.getSearchGroups(data, 'base="([^"]+?)"')[0]
  2206. src = self.cm.ph.getSearchGroups(data, 'src="([^"]+?)"')[0]
  2207. if ':' in src:
  2208. src = src.split(':')[1]
  2209. if base.startswith('rtmp'):
  2210. return base + '/' + src + ' swfUrl=%s live=1 pageUrl=%s' % (SWF_URL, baseUrl)
  2211. return False
  2212. def parserVIDZER(self, baseUrl):
  2213. printDBG("parserVIDZER baseUrl[%s]" % baseUrl)
  2214. try:
  2215. sts, data = self.cm.getPage(baseUrl)
  2216. if not sts: return False
  2217. url = self.cm.ph.getSearchGroups(data, '<iframe src="(http[^"]+?)"')[0]
  2218. if url != '':
  2219. sts, data = self.cm.getPage(url)
  2220. if not sts: return False
  2221. data = CParsingHelper.getDataBeetwenMarkers(data, '<div id="playerVidzer">', '</a>', False)[1]
  2222. match = re.search('href="(http[^"]+?)"', data)
  2223. if match:
  2224. url = urllib.unquote( match.group(1) )
  2225. return url
  2226. r = re.search('value="(.+?)" name="fuck_you"', data)
  2227. r2 = re.search('name="confirm" type="submit" value="(.+?)"', data)
  2228. r3 = re.search('<a href="/file/([^"]+?)" target', data)
  2229. if r:
  2230. printDBG("r_1[%s]" % r.group(1))
  2231. printDBG("r_2[%s]" % r2.group(1))
  2232. data = 'http://www.vidzer.net/e/'+r3.group(1)+'?w=631&h=425'
  2233. postdata = {'confirm' : r2.group(1), 'fuck_you' : r.group(1)}
  2234. sts, data = self.cm.getPage(data, {}, postdata)
  2235. match = re.search("url: '([^']+?)'", data)
  2236. if match:
  2237. url = match.group(1) #+ '|Referer=http://www.vidzer.net/media/flowplayer/flowplayer.commercial-3.2.18.swf'
  2238. return url
  2239. else:
  2240. return False
  2241. else:
  2242. return False
  2243. except:
  2244. printExc()
  2245. return False
  2246. def parserNOWVIDEOCH(self, url):
  2247. printDBG("parserNOWVIDEOCH url[%s]" % url)
  2248. return self._parserUNIVERSAL_B(url)
  2249. def parserSTREAMINTO(self, baseUrl):
  2250. printDBG("parserSTREAMINTO baseUrl[%s]" % baseUrl)
  2251. # example video: http://streamin.to/okppigvwdk8w
  2252. # http://streamin.to/embed-rme4hyg6oiou-640x500.html
  2253. #tmp = self.__parseJWPLAYER_A(baseUrl, 'streamin.to')
  2254. def getPageUrl(data):
  2255. #printDBG("=======================================")
  2256. #printDBG(data)
  2257. #printDBG("=======================================")
  2258. vidTab = []
  2259. streamer = self.cm.ph.getSearchGroups(data, 'streamer: "(rtmp[^"]+?)"')[0]
  2260. printDBG(streamer)
  2261. data = re.compile('file:[ ]*?"([^"]+?)"').findall(data)
  2262. for item in data:
  2263. if item.startswith('http://'):
  2264. vidTab.insert(0, {'name': 'http://streamin.to/ ', 'url':item})
  2265. elif item.startswith('rtmp://') or '' != streamer:
  2266. try:
  2267. if item.startswith('rtmp://'):
  2268. item = item.split('flv:')
  2269. r = item[0]
  2270. playpath = item[1]
  2271. else:
  2272. r = streamer
  2273. playpath = item
  2274. swfUrl = "http://streamin.to/player6/jwplayer.flash.swf"
  2275. rtmpUrl = r + ' playpath=%s' % playpath + ' swfUrl=%s' % swfUrl + ' pageUrl=%s' % baseUrl
  2276. vidTab.append({'name': 'rtmp://streamin.to/ ', 'url':urlparser.decorateUrl(rtmpUrl, {'iptv_livestream':False})})
  2277. except:
  2278. printExc()
  2279. return vidTab
  2280. vidTab = []
  2281. if 'embed' not in baseUrl:
  2282. baseUrl = 'http://streamin.to/embed-%s-640x500.html' % baseUrl.split('/')[-1]
  2283. HTTP_HEADER = {"User-Agent":"Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10"}
  2284. sts, data = self.cm.getPage(baseUrl, {'header' : HTTP_HEADER})
  2285. if sts:
  2286. errMarkers = ['File was deleted', 'File Removed', 'File Deleted.']
  2287. for errMarker in errMarkers:
  2288. if errMarker in data:
  2289. SetIPTVPlayerLastHostError(errMarker)
  2290. vidTab = getPageUrl(data)
  2291. if 0 == len(vidTab):
  2292. cookies_data = ''
  2293. cookies = re.findall("cookie\('([^']*)', '([^']*)'", data)
  2294. for item in cookies:
  2295. cookies_data += '%s=%s;' % (item[0], item[1])
  2296. sts, data = self.cm.ph.getDataBeetwenMarkers(data, 'method="POST"', '</Form>', False)
  2297. post_data = dict(re.findall(r'<input[^>]*name="([^"]*)"[^>]*value="([^"]*)"[^>]*>', data))
  2298. HTTP_HEADER['Referer'] = baseUrl
  2299. # get cookie for streamin.to
  2300. if len(cookies_data):
  2301. HTTP_HEADER['Cookie'] = cookies_data[:-1]
  2302. try:
  2303. sleep_time = int(self.cm.ph.getSearchGroups(data, '<span id="cxc">([0-9])</span>')[0])
  2304. time.sleep(sleep_time)
  2305. except:
  2306. printExc()
  2307. sts, data = self.cm.getPage(baseUrl, {'header' : HTTP_HEADER}, post_data)
  2308. if sts:
  2309. vidTab = getPageUrl(data)
  2310. return vidTab
  2311. def parseVSHAREIO(self, baseUrl):
  2312. printDBG("parseVSHAREIO baseUrl[%s]" % baseUrl)
  2313. # example video:
  2314. # http://vshare.io/v/72f9061/width-470/height-305/
  2315. # http://vshare.io/v/72f9061/width-470/height-305/
  2316. # http://vshare.io/d/72f9061/1
  2317. video_id = self.cm.ph.getSearchGroups(baseUrl+'/', '/[dv]/([A-Za-z0-9]{7})/')[0]
  2318. url = 'http://vshare.io/v/{0}/width-470/height-305/'.format(video_id)
  2319. HTTP_HEADER= { 'User-Agent':'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:21.0) Gecko/20100101 Firefox/21.0', 'Referer':baseUrl}
  2320. vidTab = []
  2321. sts, data = self.cm.getPage(url, {'header' : HTTP_HEADER})
  2322. if not sts: return
  2323. stream = self.cm.ph.getSearchGroups(data, '''['"](http://[^"^']+?/stream\,[^"^']+?)['"]''')[0]
  2324. if '' == stream: stream = byteify(json.loads('"%s"' % self.cm.ph.getSearchGroups(data, '''['"](http://[^"^']+?\.flv)['"]''')[0]))
  2325. if '' != stream:
  2326. vidTab.append({'name': 'http://vshare.io/stream ', 'url':stream})
  2327. if 0 == len(vidTab):
  2328. data = self.cm.ph.getDataBeetwenMarkers(data, 'clip:', '}', False)[1]
  2329. url = byteify(json.loads('"%s"' % self.cm.ph.getSearchGroups(data, '''['"](http[^"^']+?)['"]''')[0]))
  2330. vidTab.append({'name': 'http://vshare.io/ ', 'url':url})
  2331. return vidTab
  2332. def parserVIDSSO(self, url):
  2333. printDBG("parserVIDSSO url[%s]" % url)
  2334. # example video: http://www.vidsso.com/video/hhbwr85FMGX
  2335. try:
  2336. sts, data = self.cm.getPage(url)
  2337. try:
  2338. confirm = re.search('<input name="([^"]+?)" [^>]+?value="([^"]+?)"', data)
  2339. vs = re.search('<input type="hidden" value="([^"]+?)" name="([^"]+?)">', data)
  2340. post = {confirm.group(1):confirm.group(2), vs.group(2):vs.group(1)}
  2341. sts, data = self.cm.getPage(url, {'Referer':url}, post)
  2342. except:
  2343. printExc()
  2344. url = re.search("'file': '(http[^']+?)'", data).group(1)
  2345. return url
  2346. except:
  2347. printExc()
  2348. return False
  2349. def parseWATTV(self, url="http://www.wat.tv/images/v70/PlayerLite.swf?videoId=6owmd"):
  2350. printDBG("parseWATTV url[%s]\n" % url)
  2351. # example video: http://www.wat.tv/video/orages-en-dordogne-festival-6xxsn_2exyh_.html
  2352. def getTS():
  2353. #ts = math.floor( float(ts) / 1000 )
  2354. url = "http://www.wat.tv/servertime?%d" % int(random() * 0x3D0900)
  2355. sts, data = self.cm.getPage(url, {'header' : HTTP_HEADER})
  2356. ts = int(data.split('|')[0])
  2357. return int2base(int(ts), 36)
  2358. def computeToken(urlSuffixe, ts):
  2359. tHex = int2base(int(ts, 36), 16)
  2360. while len(tHex) < 8:
  2361. tHex = "0" + tHex
  2362. constToken = "9b673b13fa4682ed14c3cfa5af5310274b514c4133e9b3a81e6e3aba009l2564"
  2363. hashAlg = MD5()
  2364. return hexlify( hashAlg(constToken + urlSuffixe + tHex) ) + "/" + tHex
  2365. movieUrls = []
  2366. HTTP_HEADER= { 'User-Agent':'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:21.0) Gecko/20100101 Firefox/21.0',
  2367. 'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' }
  2368. HTTP_HEADER['Referer'] = url
  2369. match = re.search("videoId=([^']+?)'", url + "'")
  2370. sts, data = self.cm.getPage(url, {'header' : HTTP_HEADER})
  2371. if sts:
  2372. real_id = re.search(r'xtpage = ".*-(.*?)";', data)
  2373. if real_id:
  2374. real_id = real_id.group(1)
  2375. movieUrls.append({'name': 'wat.tv: Mobile', 'url':'http://wat.tv/get/android5/%s.mp4' % real_id})
  2376. if not match:
  2377. match = re.search('videoId=([^"]+?)"', data)
  2378. for item in ["webhd", "web"]:
  2379. try:
  2380. vidId = int(match.group(1), 36)
  2381. url_0 = "/%s/%d" % (item, vidId)
  2382. url_1 = computeToken(url_0, getTS())
  2383. url_2 = url_0 + "?token=" + url_1 + "&"
  2384. url = "http://www.wat.tv/get" + url_2 + "domain=www.wat.tv&refererURL=www.wat.tv&revision=04.00.388%0A&synd=0&helios=1&context=playerWat&pub=5&country=FR&sitepage=WAT%2Ftv%2Fu%2Fvideo&lieu=wat&playerContext=CONTEXT_WAT&getURL=1&version=WIN%2012,0,0,44"
  2385. printDBG("====================================================: [%s]\n" % url)
  2386. sts, url = self.cm.getPage(url, {'header' : HTTP_HEADER})
  2387. if sts:
  2388. if url.split('?')[0].endswith('.f4m'):
  2389. url = urlparser.decorateUrl(url, HTTP_HEADER)
  2390. retTab = getF4MLinksWithMeta(url)
  2391. movieUrls.extend(retTab)
  2392. elif 'ism' not in url:
  2393. movieUrls.append({'name': 'wat.tv: ' + item, 'url':url})
  2394. except:
  2395. printExc()
  2396. movieUrls.reverse()
  2397. return movieUrls
  2398. def parseTUNEPK(self, url):
  2399. printDBG("parseTUNEPK url[%s]\n" % url)
  2400. # example video: http://tune.pk/video/4203444/top-10-infamous-mass-shootings-in-the-u
  2401. for item in ['vid=', '/video/', '/play/']:
  2402. vid = self.cm.ph.getSearchGroups(url+'&', item+'([0-9]+)[^0-9]')[0]
  2403. if '' != vid: break
  2404. if '' == vid: return []
  2405. url = 'http://embed.tune.pk/play/%s?autoplay=no&ssl=no' % vid
  2406. return self.__parseJWPLAYER_A(url, 'tune.pk')
  2407. def parserVIDEOTT(self, url):
  2408. printDBG("parserVIDEOTT url[%r]" % url)
  2409. # based on https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/videott.py
  2410. # example video: http://www.video.tt/video/HRKwm3EhI
  2411. linkList = []
  2412. try:
  2413. mobj = re.match(r'http://(?:www\.)?video\.tt/(?:video/|watch_video\.php\?v=|embed/)(?P<id>[\da-zA-Z]{9})', url)
  2414. video_id = mobj.group('id')
  2415. except:
  2416. printExc()
  2417. return linkList
  2418. url = 'http://www.video.tt/player_control/settings.php?v=%s' % video_id
  2419. sts, data = self.cm.getPage(url)
  2420. if sts:
  2421. try:
  2422. data = json.loads(data)['settings']
  2423. linkList = [
  2424. {
  2425. 'url': base64.b64decode(res['u'].encode('utf-8')),
  2426. 'name': res['l'].encode('utf-8'),
  2427. } for res in data['res'] if res['u']
  2428. ]
  2429. except:
  2430. printExc()
  2431. return linkList
  2432. def parserEXASHARECOM(self, url):
  2433. printDBG("parserEXASHARECOM url[%r]" % url)
  2434. # example video: http://www.exashare.com/s4o73bc1kd8a
  2435. HTTP_HEADER = { 'User-Agent':"Mozilla/5.0", 'Referer':url }
  2436. if 'exashare.com' in url:
  2437. sts, data = self.cm.getPage(url, {'header' : HTTP_HEADER})
  2438. if not sts: return
  2439. url = self.cm.ph.getSearchGroups(data, '''<iframe[^>]+?src=["'](http[^"^']+?)["']''', 1, True)[0].replace('\n', '').replace('\r', '')
  2440. printDBG(">>>>>>>>>>>>>>>>>>>>>>>>>>> url[%s]\n" % url)
  2441. def _findLinks(data):
  2442. return self._findLinks(data, 'exashare.com', m1='setup(', m2=')')
  2443. return self.__parseJWPLAYER_A(url, 'exashare.com', _findLinks, folowIframe=True)
  2444. def parserALLVIDCH(self, baseUrl):
  2445. printDBG("parserALLVIDCH baseUrl[%r]" % baseUrl)
  2446. # example video: http://allvid.ch/embed-fhpd7sk5ac2o-830x500.html
  2447. HTTP_HEADER = { 'User-Agent':"Mozilla/5.0", 'Referer':baseUrl }
  2448. params = {'header' : HTTP_HEADER, 'cookiefile':GetCookieDir('allvidch.cookie'), 'use_cookie': True, 'save_cookie':True, 'load_cookie':True}
  2449. def _findLinks(data):
  2450. return self._findLinks(data, 'allvid.ch', m1='setup(', m2='image:')
  2451. def _preProcessing(data):
  2452. url2 = self.cm.ph.getSearchGroups(data, '''<iframe[^>]*?src=["'](http[^"^']+?)["']''', 1, True)[0]
  2453. if url2.startswith('http'):
  2454. sts, data2 = self.cm.getPage(url2, params)
  2455. if sts:
  2456. return data2
  2457. return data
  2458. return self._parserUNIVERSAL_A(baseUrl, 'http://allvid.ch/embed-{0}-830x500.html', _findLinks, _preProcessing, HTTP_HEADER, params)
  2459. #return self.__parseJWPLAYER_A(baseUrl, 'allvid.ch', _findLinks)
  2460. def parserALBFILMCOM(self, baseUrl):
  2461. printDBG("parserALBFILMCOM baseUrl[%r]" % baseUrl)
  2462. # www.albfilm.com/video/?m=endless_love_2014
  2463. def _findLinks(data):
  2464. videoUrl = self.cm.ph.getSearchGroups(data, '''<source[^>]+?src=["'](http[^"^']+?)["']''', 1, True)[0]
  2465. if videoUrl == '': return []
  2466. return [{'name':'albfilm.com', 'url':videoUrl}]
  2467. url = baseUrl
  2468. return self._parserUNIVERSAL_A(baseUrl, url, _findLinks)
  2469. def parserVIDAG(self, baseUrl):
  2470. printDBG("parserVIDAG baseUrl[%r]" % baseUrl)
  2471. # example video: http://vid.ag/embed-24w6kstkr3zt-540x360.html
  2472. def _findLinks(data):
  2473. tab = []
  2474. tmp = self._findLinks(data, 'vid.ag', m1='setup(', m2='image:')
  2475. for item in tmp:
  2476. if not item['url'].split('?')[0].endswith('.m3u8'):
  2477. tab.append(item)
  2478. return tab
  2479. HTTP_HEADER= { 'User-Agent':"Mozilla/5.0", 'Referer':'http://www.streaming-series.xyz/', 'Cookie':'__test' }
  2480. return self._parserUNIVERSAL_A(baseUrl, 'http://vid.ag/embed-{0}-540x360.html', _findLinks, None, HTTP_HEADER)
  2481. def parserVODLOCKER(self, url):
  2482. printDBG("parserVODLOCKER url[%r]" % url)
  2483. # example video: http://vodlocker.com/txemekqfbopy
  2484. return self.__parseJWPLAYER_A(url, 'vodlocker.com')
  2485. def parserVSHAREEU(self, url):
  2486. printDBG("parserVSHAREEU url[%r]" % url)
  2487. # example video: http://vshare.eu/mvqdaea0m4z0.htm
  2488. return self.__parseJWPLAYER_A(url, 'vshare.eu')
  2489. def parserVIDSPOT(self, url):
  2490. printDBG("parserVIDSPOT url[%r]" % url)
  2491. # example video: http://vidspot.net/2oeqp21cdsee
  2492. return self.__parseJWPLAYER_A(url, 'vidspot.net')
  2493. def parserVIDBULL(self, baseUrl):
  2494. printDBG("parserVIDBULL baseUrl[%s]" % baseUrl)
  2495. # example video: http://vidbull.com/zsi9kwq0eqm4.html
  2496. HTTP_HEADER = dict(self.HTTP_HEADER)
  2497. HTTP_HEADER['Referer'] = baseUrl
  2498. # we will try three times if they tell us that we wait to short
  2499. tries = 0
  2500. while tries < 3:
  2501. # get embedded video page and save returned cookie
  2502. sts, data = self.cm.getPage(baseUrl, {'header' : HTTP_HEADER})
  2503. if not sts: return False
  2504. sts, data = self.cm.ph.getDataBeetwenMarkers(data, '<input type="hidden" name="op" value="download2">', '</Form>', True)
  2505. post_data = dict(re.findall(r'<input[^>]*name="([^"]*)"[^>]*value="([^"]*)"[^>]*>', data))
  2506. try:
  2507. sleep_time = int(self.cm.ph.getSearchGroups(data, '>([0-9])</span> seconds<')[0])
  2508. time.sleep(sleep_time)
  2509. except:
  2510. printExc()
  2511. if {} == post_data:
  2512. post_data = None
  2513. sts, data = self.cm.getPage(baseUrl, {'header' : HTTP_HEADER}, post_data)
  2514. if not sts: return False
  2515. if 'Skipped countdown' in data:
  2516. tries += tries
  2517. continue # we will try three times if they tell us that we wait to short
  2518. # get JS player script code from confirmation page
  2519. sts, tmp = self.cm.ph.getDataBeetwenMarkers(data, '<div id="player_code"', '</div>', True)
  2520. sts, tmp = self.cm.ph.getDataBeetwenMarkers(tmp, ">eval(", '</script>')
  2521. if sts:
  2522. # unpack and decode params from JS player script code
  2523. data = unpackJSPlayerParams(tmp, VIDUPME_decryptPlayerParams)
  2524. printDBG(data)
  2525. # get direct link to file from params
  2526. src = self.cm.ph.getSearchGroups(data, 'src="([^"]+?)"')[0]
  2527. if src.startswith('http'):
  2528. return src
  2529. # get direct link to file from params
  2530. file = self.cm.ph.getSearchGroups(data, r'''['"]?file['"]?[ ]*:[ ]*['"]([^"^']+)['"],''')[0]
  2531. if '' != file:
  2532. if file.startswith('http'): return src
  2533. else:
  2534. key = 'YTk0OTM3NmUzN2IzNjlmMTdiYzdkM2M3YTA0YzU3MjE='
  2535. bkey, knownCipherText = a2b_hex(base64.b64decode(key)), a2b_hex(file)
  2536. kSize = len(bkey)
  2537. alg = AES(bkey, keySize=kSize, padding=noPadding())
  2538. file = alg.decrypt(knownCipherText).split('\x00')[0]
  2539. if file.startswith('http'):
  2540. return file
  2541. break
  2542. return False
  2543. def parserDIVEXPRESS(self, baseUrl):
  2544. printDBG("parserDIVEXPRESS baseUrl[%s]" % baseUrl)
  2545. # example video: http://divxpress.com/h87ygyutusp6/The.Last.Ship.S01E04.HDTV.x264-LOL_Napisy_PL.AVI.html
  2546. return self.parserVIDBULL(baseUrl)
  2547. def parserPROMPTFILE(self, baseUrl):
  2548. printDBG("parserPROMPTFILE baseUrl[%s]" % baseUrl)
  2549. sts, data = self.cm.getPage(baseUrl)
  2550. if sts:
  2551. HTTP_HEADER = dict(self.HTTP_HEADER)
  2552. HTTP_HEADER['Referer'] = baseUrl
  2553. if 'Continue to File' in data:
  2554. sts, data = self.cm.ph.getDataBeetwenMarkers(data, '<form method="post" action="">', '</form>', False, False)
  2555. post_data = dict(re.findall(r'<input[^>]*name="([^"]*)"[^>]*value="([^"]*)"[^>]*>', data))
  2556. params = {'header' : HTTP_HEADER, 'cookiefile':GetCookieDir('promptfile.cookie'), 'use_cookie': True, 'save_cookie':True, 'load_cookie':False}
  2557. sts, data = self.cm.getPage(baseUrl, params, post_data)
  2558. if not sts:
  2559. return False
  2560. data = self.cm.ph.getSearchGroups(data, """url: ["'](http[^"']+?)["'],""")[0]
  2561. if '' != data:
  2562. return data
  2563. return False
  2564. def parserPLAYEREPLAY(self, baseUrl):
  2565. printDBG("parserPLAYEREPLAY baseUrl[%s]" % baseUrl)
  2566. videoIDmarker = "((?:[0-9]){5}\.(?:[A-Za-z0-9]){28})"
  2567. HTTP_HEADER = {'User-Agent': "Mozilla/5.0 (Linux; U; Android 4.1.1; en-us; androVM for VirtualBox ('Tablet' version with phone caps) Build/JRO03S) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30"}
  2568. COOKIE_FILE = GetCookieDir('playreplaynet.cookie')
  2569. params = {'header':HTTP_HEADER, 'cookiefile':COOKIE_FILE, 'use_cookie': True, 'save_cookie':True}
  2570. sts, data = self.cm.getPage(baseUrl, params)
  2571. if sts:
  2572. data = self.cm.ph.getSearchGroups(data, videoIDmarker)[0]
  2573. if data == '':
  2574. data = self.cm.ph.getSearchGroups(baseUrl, videoIDmarker)[0]
  2575. if '' != data:
  2576. HTTP_HEADER['Referer'] = baseUrl
  2577. post_data = {'r':'[["file/flv_link2",{"uid":"%s","link":true}],["file/flv_image",{"uid":"%s","link":true}]]' % (data, data)}
  2578. #
  2579. params['header'] = HTTP_HEADER
  2580. params['load_cookie'] = True
  2581. sts, data = self.cm.getPage('http://playreplay.net/data', params, post_data)
  2582. printDBG(data)
  2583. if sts:
  2584. data = byteify(json.loads(data))['data'][0]
  2585. if 'flv' in data[0]:
  2586. return strwithmeta(data[0], {'Range':'0', 'iptv_buffering':'required'})
  2587. return False
  2588. def parserVIDEOWOODTV(self, baseUrl):
  2589. printDBG("parserVIDEOWOODTV baseUrl[%s]" % baseUrl)
  2590. HTTP_HEADER= { 'User-Agent':"Mozilla/5.0", 'Referer':baseUrl }
  2591. if 'embed' not in baseUrl:
  2592. video_id = self.cm.ph.getSearchGroups(baseUrl+'/', '/([A-Za-z0-9]{4})/')[0]
  2593. url = 'http://videowood.tv/embed/{0}'.format(video_id)
  2594. else:
  2595. url = baseUrl
  2596. params = {'header' : HTTP_HEADER}
  2597. sts, data = self.cm.getPage(url, params)
  2598. if not sts: return False
  2599. while True:
  2600. vidUrl = self.cm.ph.getSearchGroups(data, """["']*file["']*:[ ]*["'](http[^"']+?(?:\.mp4|\.flv)[^"']*?)["']""")[0]
  2601. if '' != vidUrl:
  2602. return vidUrl.replace('\\/', '/')
  2603. sts, data = self.cm.ph.getDataBeetwenMarkers(data, "eval(", '</script>')
  2604. if sts:
  2605. # unpack and decode params from JS player script code
  2606. data = unpackJSPlayerParams(data, TEAMCASTPL_decryptPlayerParams)
  2607. #data = self.cm.ph.getDataBeetwenMarkers(data, 'config=', ';',
  2608. printDBG(data)
  2609. continue
  2610. break
  2611. return False
  2612. def parserMOVRELLCOM(self, baseUrl):
  2613. printDBG("parserMOVRELLCOM baseUrl[%s]" % baseUrl)
  2614. sts, data = self.cm.getPage(baseUrl)
  2615. if sts:
  2616. HTTP_HEADER = dict(self.HTTP_HEADER)
  2617. HTTP_HEADER['Referer'] = baseUrl
  2618. if 'Watch as Free User' in data:
  2619. sts, data = self.cm.ph.getDataBeetwenMarkers(data, '<form', '</form>', False, False)
  2620. post_data = dict(re.findall(r'<input[^>]*name="([^"]*)"[^>]*value="([^"]*)"[^>]*>', data))
  2621. params = {'header' : HTTP_HEADER}
  2622. sts, data = self.cm.getPage(baseUrl, params, post_data)
  2623. if not sts:
  2624. return False
  2625. # get JS player script code from confirmation page
  2626. sts, tmp = self.cm.ph.getDataBeetwenMarkers(data, '<div id="player_code"', '</div>', True)
  2627. sts, tmp = self.cm.ph.getDataBeetwenMarkers(tmp, ">eval(", '</script>')
  2628. if sts:
  2629. # unpack and decode params from JS player script code
  2630. data = unpackJSPlayerParams(tmp, VIDUPME_decryptPlayerParams)
  2631. printDBG(data)
  2632. # get direct link to file from params
  2633. src = self.cm.ph.getSearchGroups(data, 'src="([^"]+?)"')[0]
  2634. if src.startswith('http'):
  2635. return src
  2636. return False
  2637. def parserVIDFILENET(self, baseUrl):
  2638. printDBG("parserVIDFILENET baseUrl[%s]" % baseUrl)
  2639. HTTP_HEADER= { 'User-Agent':"Mozilla/5.0", 'Referer':baseUrl }
  2640. params = {'header' : HTTP_HEADER}
  2641. sts, data = self.cm.getPage(baseUrl, params)
  2642. if sts:
  2643. data = self.cm.ph.getSearchGroups(data, """["']*file["']*:[ ]*["'](http[^"']+?)["']""")[0]
  2644. if '' != data:
  2645. return data
  2646. return False
  2647. def parserMP4UPLOAD(self, baseUrl):
  2648. printDBG("parserMP4UPLOAD baseUrl[%s]" % baseUrl)
  2649. videoUrls = []
  2650. sts, data = self.cm.getPage(baseUrl)
  2651. #printDBG(data)
  2652. if sts:
  2653. data = CParsingHelper.getDataBeetwenMarkers(data, "'modes':", ']', False)[1]
  2654. data = re.compile("""['"]file['"]: ['"]([^'^"]+?)['"]""").findall(data)
  2655. if 1 < len(data) and data[1].startswith('http'): videoUrls.append( {'name': 'mp4upload.com: html5', 'url':data[1] } )
  2656. if 0 < len(data) and data[0].startswith('http'): videoUrls.append( {'name': 'mp4upload.com: download', 'url':data[0] } )
  2657. return videoUrls
  2658. def parserYUKONS(self, baseUrl):
  2659. printDBG("parserYUKONS url[%s]" % baseUrl)
  2660. #http://yukons.net/watch/willstream002?Referer=wp.pl
  2661. def _resolveChannelID(channel):
  2662. def _decToHex(a):
  2663. b = hex(a)[2:]
  2664. if 1 == len(b):
  2665. return '0'+b
  2666. else:
  2667. return b
  2668. def _resolve(a):
  2669. b = ''
  2670. for i in range(len(a)):
  2671. b += _decToHex(ord(a[i]))
  2672. return b
  2673. return _resolve( _resolve(channel) )
  2674. baseUrl = urlparser.decorateParamsFromUrl(baseUrl)
  2675. shortChannelId = baseUrl.split('?')[0].split('/')[-1]
  2676. Referer = baseUrl.meta.get('Referer', '')
  2677. HTTP_HEADER = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3 Gecko/2008092417 Firefox/3.0.3', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Referer' : Referer}
  2678. COOKIE_FILE = GetCookieDir('yukonsnet.cookie')
  2679. params = {'header':HTTP_HEADER, 'cookiefile':COOKIE_FILE, 'use_cookie': True, 'save_cookie':True}
  2680. longChannelId = _resolveChannelID(shortChannelId)
  2681. url1 = 'http://yukons.net/yaem/' + longChannelId
  2682. sts, data = self.cm.getPage(url1, params)
  2683. if sts:
  2684. kunja = re.search("'([^']+?)';", data).group(1)
  2685. url2 = 'http://yukons.net/embed/' + longChannelId + '/' + kunja + '/680/400'
  2686. params.update({'save_cookie' : False, 'load_cookie' : True})
  2687. sts, data = self.cm.getPage(url2, params)
  2688. if sts:
  2689. data = CParsingHelper.getDataBeetwenMarkers(data, "eval(", '</script>', False)[1]
  2690. data = unpackJSPlayerParams(data, VIDUPME_decryptPlayerParams, 0)
  2691. printDBG(data)
  2692. id = CParsingHelper.getDataBeetwenMarkers(data, "id=", '&', False)[1]
  2693. pid = CParsingHelper.getDataBeetwenMarkers(data, "pid=", '&', False)[1]
  2694. data = CParsingHelper.getDataBeetwenMarkers(data, "eval(", '</script>', False)[1]
  2695. sts, data = self.cm.getPage("http://yukons.net/srvload/"+id, params)
  2696. printDBG(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [%s]" % data)
  2697. if sts:
  2698. ip = data[4:].strip()
  2699. url = 'rtmp://%s:443/kuyo playpath=%s?id=%s&pid=%s swfVfy=http://yukons.net/yplay2.swf pageUrl=%s conn=S:OK live=1' % (ip, shortChannelId, id, pid, url2)
  2700. return url
  2701. return False
  2702. def parserUSTREAMTV(self, linkUrl):
  2703. printDBG("parserUSTREAMTV linkUrl[%s]" % linkUrl)
  2704. #http://www.ustream.tv/channel/nasa-educational
  2705. linksTab = []
  2706. live = True
  2707. # get PC streams
  2708. while True:
  2709. channelID = self.cm.ph.getSearchGroups(linkUrl+'|', "cid=([0-9]+?)[^0-9]")[0]
  2710. if '' == channelID:
  2711. sts, data = self.cm.getPage(linkUrl)
  2712. if not sts: break
  2713. channelID = self.cm.ph.getSearchGroups(data, 'data-content-id="([0-9]+?)"')[0]
  2714. if '' == channelID: channelID = self.cm.ph.getSearchGroups(data, 'ustream.vars.contentId=([0-9]+?)[^0-9]')[0]
  2715. if '' == channelID: break
  2716. #in linkUrl and 'ustream.vars.isLive=true' not in data and '/live/' not in linkUrl
  2717. if '/recorded/' in linkUrl:
  2718. videoUrl = 'https://www.ustream.tv/recorded/' + channelID
  2719. live = False
  2720. else:
  2721. videoUrl = 'https://www.ustream.tv/embed/' + channelID
  2722. live = True
  2723. baseWgetCmd = DMHelper.getBaseWgetCmd({})
  2724. cmd = DMHelper.GET_F4M_PATH() + (" '%s'" % baseWgetCmd) + (' "%s"' % videoUrl) + ' 2>&1 > /dev/null'
  2725. printDBG("parserUSTREAMTV cmd[%s" % cmd)
  2726. data = iptv_execute()( cmd )
  2727. printDBG(data)
  2728. if not data['sts'] or 0 != data['code']:
  2729. break
  2730. try:
  2731. data = json.loads(data['data'])
  2732. for item in data['stream_info_list']:
  2733. if not live and item['chunk_name'].startswith('http'):
  2734. url = urlparser.decorateUrl(item['chunk_name'].encode('utf-8'))
  2735. linksTab.append({'name':'ustream.tv recorded', 'url': url})
  2736. else:
  2737. name = 'ustream.tv ' + item['stream_name'].encode('utf-8')
  2738. chankUrl = (item['prov_url'] + item['chunk_name']).encode('utf-8')
  2739. url = urlparser.decorateUrl(videoUrl, {'iptv_livestream': True, 'iptv_proto':'f4m', 'iptv_chank_url':chankUrl})
  2740. linksTab.append({'name':name, 'url':url})
  2741. except:
  2742. printExc()
  2743. break
  2744. return linksTab
  2745. # get mobile streams
  2746. if live:
  2747. playlist_url = "http://iphone-streaming.ustream.tv/uhls/%s/streams/live/iphone/playlist.m3u8" % channelID
  2748. if 0 == len(linksTab): attempts = 5
  2749. else: attempts = 1
  2750. while attempts:
  2751. try:
  2752. retTab = getDirectM3U8Playlist(playlist_url)
  2753. if len(retTab):
  2754. for item in retTab:
  2755. name = ('ustream.tv %s' % item.get('heigth', 0)) + '_mobile'
  2756. url = urlparser.decorateUrl(item['url'], {'iptv_livestream': True})
  2757. linksTab.append({'name':name, 'url':url})
  2758. break
  2759. except:
  2760. printExc()
  2761. attempts -= 1
  2762. time.sleep(3)
  2763. return linksTab
  2764. def parserPRIVATESTREAM(self, linkUrl):
  2765. printDBG("parserPRIVATESTREAM linkUrl[%s]" % linkUrl)
  2766. HTTP_HEADER = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3 Gecko/2008092417 Firefox/3.0.3', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'}
  2767. videoUrl = strwithmeta(linkUrl)
  2768. if 'Referer' in videoUrl.meta:
  2769. HTTP_HEADER['Referer'] = videoUrl.meta['Referer']
  2770. if videoUrl.split('?')[0].endswith('.js'):
  2771. sts, data = self.cm.getPage(videoUrl, {'header': HTTP_HEADER})
  2772. if not sts: return False
  2773. printDBG(data)
  2774. tr = 0
  2775. while tr < 3:
  2776. tr += 1
  2777. videoUrl = self.cm.ph.getSearchGroups(data, '"(http://privatestream.tv/player?[^"]+?)"')[0]
  2778. if "" != videoUrl: break
  2779. time.sleep(1)
  2780. sts, data = self.cm.getPage(videoUrl, {'header': HTTP_HEADER})
  2781. printDBG(data)
  2782. if sts:
  2783. try:
  2784. a = int(self.cm.ph.getSearchGroups(data, 'var a = ([0-9]+?);')[0])
  2785. b = int(self.cm.ph.getSearchGroups(data, 'var b = ([0-9]+?);')[0])
  2786. c = int(self.cm.ph.getSearchGroups(data, 'var c = ([0-9]+?);')[0])
  2787. d = int(self.cm.ph.getSearchGroups(data, 'var d = ([0-9]+?);')[0])
  2788. f = int(self.cm.ph.getSearchGroups(data, 'var f = ([0-9]+?);')[0])
  2789. v_part = self.cm.ph.getSearchGroups(data, "var v_part = '([^']+?)'")[0]
  2790. url = ('rtmp://%d.%d.%d.%d' % (a/f, b/f, c/f, d/f) ) + v_part
  2791. url += ' swfUrl=http://privatestream.tv/js/jwplayer.flash.swf pageUrl=%s' % (videoUrl)
  2792. return url
  2793. except:
  2794. printExc()
  2795. return False
  2796. def parserABCASTBIZ(self, linkUrl):
  2797. printDBG("parserABCASTBIZ linkUrl[%s]" % linkUrl)
  2798. HTTP_HEADER = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3 Gecko/2008092417 Firefox/3.0.3', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'}
  2799. videoUrl = strwithmeta(linkUrl)
  2800. if 'Referer' in videoUrl.meta:
  2801. HTTP_HEADER['Referer'] = videoUrl.meta['Referer']
  2802. sts, data = self.cm.getPage(linkUrl, {'header': HTTP_HEADER})
  2803. if not sts: return False
  2804. swfUrl = "http://abcast.net/player.swf"
  2805. file = self.cm.ph.getSearchGroups(data, 'file=([^&]+?)&')[0]
  2806. if file.endswith(".flv"): file = file[0:-4]
  2807. streamer = self.cm.ph.getSearchGroups(data, 'streamer=([^&]+?)&')[0]
  2808. if '' != file:
  2809. url = "rtmpe://live.abcast.biz/redirect"
  2810. url = streamer
  2811. url += ' playpath=%s swfUrl=%s pageUrl=%s' % (file, swfUrl, linkUrl)
  2812. printDBG(url)
  2813. return url
  2814. data = self.cm.ph.getDataBeetwenMarkers(data, 'setup({', '});', True)[1]
  2815. url = self.cm.ph.getSearchGroups(data, 'streamer[^"]+?"(rtmp[^"]+?)"')[0]
  2816. file = self.cm.ph.getSearchGroups(data, 'file[^"]+?"([^"]+?)"')[0]
  2817. if '' != file and '' != url:
  2818. url += ' playpath=%s swfUrl=%s pageUrl=%s ' % (file, swfUrl, linkUrl)
  2819. return url
  2820. return False
  2821. def parserOPENLIVEORG(self, linkUrl):
  2822. printDBG("parserOPENLIVEORG linkUrl[%s]" % linkUrl)
  2823. HTTP_HEADER = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3 Gecko/2008092417 Firefox/3.0.3', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'}
  2824. videoUrl = strwithmeta(linkUrl)
  2825. if 'Referer' in videoUrl.meta:
  2826. HTTP_HEADER['Referer'] = videoUrl.meta['Referer']
  2827. sts, data = self.cm.getPage(linkUrl, {'header': HTTP_HEADER})
  2828. if not sts: return False
  2829. file = self.cm.ph.getSearchGroups(data, 'file=([^&]+?)&')[0]
  2830. if file.endswith(".flv"): file = file[0:-4]
  2831. streamer = self.cm.ph.getSearchGroups(data, 'streamer=([^&]+?)&')[0]
  2832. swfUrl = "http://openlive.org/player.swf"
  2833. if '' != file:
  2834. url = streamer
  2835. url += ' playpath=%s swfUrl=%s pageUrl=%s' % (file, swfUrl, linkUrl)
  2836. printDBG(url)
  2837. return url
  2838. data = self.cm.ph.getDataBeetwenMarkers(data, 'setup({', '});', True)[1]
  2839. url = self.cm.ph.getSearchGroups(data, 'streamer[^"]+?"(rtmp[^"]+?)"')[0]
  2840. file = self.cm.ph.getSearchGroups(data, 'file[^"]+?"([^"]+?)"')[0]
  2841. if '' != file and '' != url:
  2842. url += ' playpath=%s swfUrl=%s pageUrl=%s ' % (file, swfUrl, linkUrl)
  2843. return url
  2844. return False
  2845. def parserGOODCASTCO(self, linkUrl):
  2846. printDBG("parserGOODCASTCO linkUrl[%s]" % linkUrl)
  2847. HTTP_HEADER = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3 Gecko/2008092417 Firefox/3.0.3', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'}
  2848. videoUrl = strwithmeta(linkUrl)
  2849. HTTP_HEADER['Referer'] = videoUrl.meta.get('Referer', videoUrl)
  2850. sts, data = self.cm.getPage(videoUrl, {'header': HTTP_HEADER})
  2851. if not sts: return False
  2852. url = self.cm.ph.getSearchGroups(data, 'streamer=([^&]+?)&')[0]
  2853. file = self.cm.ph.getSearchGroups(data, 'file=([0-9]+?)&')[0]
  2854. if '' != file and '' != url:
  2855. url += ' playpath=%s swfUrl=http://abcast.biz/ab.swf pageUrl=%s token=Fo5_n0w?U.rA6l3-70w47ch' % (file, linkUrl)
  2856. return url
  2857. return False
  2858. def paserLIVEALLTV(self, linkUrl):
  2859. printDBG("paserLIVEALLTV linkUrl[%s]" % linkUrl)
  2860. HTTP_HEADER = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3 Gecko/2008092417 Firefox/3.0.3', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'}
  2861. videoUrl = strwithmeta(linkUrl)
  2862. HTTP_HEADER['Referer'] = videoUrl.meta.get('Referer', videoUrl)
  2863. sts, data = self.cm.getPage(videoUrl, {'header': HTTP_HEADER})
  2864. if not sts: return False
  2865. a = int(self.cm.ph.getSearchGroups(data, 'var a = ([0-9]+?);')[0])
  2866. b = int(self.cm.ph.getSearchGroups(data, 'var b = ([0-9]+?);')[0])
  2867. c = int(self.cm.ph.getSearchGroups(data, 'var c = ([0-9]+?);')[0])
  2868. d = int(self.cm.ph.getSearchGroups(data, 'var d = ([0-9]+?);')[0])
  2869. f = int(self.cm.ph.getSearchGroups(data, 'var f = ([0-9]+?);')[0])
  2870. v_part = self.cm.ph.getSearchGroups(data, "var v_part = '([^']+?)'")[0]
  2871. url = ('rtmp://%d.%d.%d.%d' % (a/f, b/f, c/f, d/f) ) + v_part
  2872. url += ' swfUrl=http://wds.liveall.tv/jwplayer.flash.swf pageUrl=%s' % (linkUrl)
  2873. return url
  2874. def paserP2PCASTTV(self, linkUrl):
  2875. printDBG("paserP2PCASTTV linkUrl[%s]" % linkUrl)
  2876. HTTP_HEADER = {}
  2877. videoUrl = strwithmeta(linkUrl)
  2878. HTTP_HEADER['Referer'] = videoUrl.meta.get('Referer', videoUrl)
  2879. HTTP_HEADER['User-Agent'] = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0"
  2880. COOKIE_FILE = GetCookieDir('p2pcasttv.cookie')
  2881. params = {'header':HTTP_HEADER, 'cookiefile':COOKIE_FILE, 'use_cookie': True, 'save_cookie':True}
  2882. sts, data = self.cm.getPage(videoUrl, params)
  2883. if not sts: return False
  2884. url = self.cm.ph.getSearchGroups(data, 'curl[^"]*?=[^"]*?"([^"]+?)"')[0]
  2885. if '' == url: url = self.cm.ph.getSearchGroups(data, 'murl[^"]*?=[^"]*?"([^"]+?)"')[0]
  2886. url = base64.b64decode(url)
  2887. if url.endswith('token='):
  2888. params['header']['Referer'] = linkUrl
  2889. params['header']['X-Requested-With'] = 'XMLHttpRequest'
  2890. params['load_cookie'] = True
  2891. sts, data = self.cm.getPage('http://p2pcast.tech/getTok.php', params)
  2892. if not sts: return False
  2893. data = byteify(json.loads(data))
  2894. url += data['token']
  2895. return urlparser.decorateUrl(url, {'Referer':'http://cdn.webplayer.pw/jwplayer.flash.swf', "User-Agent": HTTP_HEADER['User-Agent']})
  2896. def parserGOOGLE(self, baseUrl):
  2897. printDBG("parserGOOGLE baseUrl[%s]" % baseUrl)
  2898. videoTab = []
  2899. _VALID_URL = r'https?://(?:(?:docs|drive)\.google\.com/(?:uc\?.*?id=|file/d/)|video\.google\.com/get_player\?.*?docid=)(?P<id>[a-zA-Z0-9_-]{28})'
  2900. mobj = re.match(_VALID_URL, baseUrl)
  2901. try:
  2902. video_id = mobj.group('id')
  2903. linkUrl = 'http://docs.google.com/file/d/' + video_id
  2904. except:
  2905. linkUrl = baseUrl
  2906. _FORMATS_EXT = {
  2907. '5': 'flv', '6': 'flv',
  2908. '13': '3gp', '17': '3gp',
  2909. '18': 'mp4', '22': 'mp4',
  2910. '34': 'flv', '35': 'flv',
  2911. '36': '3gp', '37': 'mp4',
  2912. '38': 'mp4', '43': 'webm',
  2913. '44': 'webm', '45': 'webm',
  2914. '46': 'webm', '59': 'mp4',
  2915. }
  2916. sts, data = self.cm.getPage(linkUrl)
  2917. if not sts: return False
  2918. fmtDict = {}
  2919. fmtList = self.cm.ph.getSearchGroups(data, '"fmt_list"[:,]"([^"]+?)"')[0]
  2920. fmtList = fmtList.split(',')
  2921. for item in fmtList:
  2922. item = self.cm.ph.getSearchGroups(item, '([0-9]+?)/([0-9]+?x[0-9]+?)/', 2)
  2923. if item[0] != '' and item[1] != '':
  2924. fmtDict[item[0]] = item[1]
  2925. data = self.cm.ph.getSearchGroups(data, '"fmt_stream_map"[:,]"([^"]+?)"')[0]
  2926. data = data.split(',')
  2927. for item in data:
  2928. item = item.split('|')
  2929. printDBG(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> type[%s]" % item[0])
  2930. if 'mp4' in _FORMATS_EXT.get(item[0], ''):
  2931. videoTab.append({'name':'google.com: %s' % fmtDict.get(item[0], '').split('x')[1] + 'p', 'url':unicode_escape(item[1])})
  2932. return videoTab[::-1]
  2933. def parserPICASAWEB(self, baseUrl):
  2934. printDBG("parserPICASAWEB baseUrl[%s]" % baseUrl)
  2935. videoTab = []
  2936. sts, data = self.cm.getPage(baseUrl)
  2937. if not sts: return videoTab
  2938. data = re.compile('(\{"url"[^}]+?\})').findall(data)
  2939. printDBG(data)
  2940. for item in data:
  2941. try:
  2942. item = byteify(json.loads(item))
  2943. if 'video' in item.get('type', ''):
  2944. videoTab.append({'name':'%sx%s' % (item.get('width', ''), item.get('height', '')), 'url':item['url']})
  2945. except:
  2946. printExc()
  2947. return videoTab
  2948. def parserMYVIRU(self, linkUrl):
  2949. printDBG("parserMYVIRU linkUrl[%s]" % linkUrl)
  2950. COOKIE_FILE = GetCookieDir('myviru.cookie')
  2951. params = {'cookiefile':COOKIE_FILE, 'use_cookie': True, 'save_cookie':True}
  2952. videoTab = []
  2953. if '/player/flash/' in linkUrl:
  2954. videoId = linkUrl.split('/')[-1]
  2955. sts, response = self.cm.getPage(linkUrl, {'return_data':False})
  2956. if not sts: return videoTab
  2957. preloaderUrl = response.geturl()
  2958. response.close()
  2959. flashApiUrl = "http://myvi.ru/player/api/video/getFlash/%s?ap=1&referer&sig&url=%s" % (videoId, urllib.quote(preloaderUrl))
  2960. sts, data = self.cm.getPage(flashApiUrl)
  2961. if not sts: return videoTab
  2962. data = data.replace('\\', '')
  2963. data = self.cm.ph.getSearchGroups(data, 'src="([^"]+?)"')[0]
  2964. if not data.startswith("//"): return videoTab
  2965. linkUrl = "http:" + data
  2966. if '/embed/html/' in linkUrl:
  2967. sts, data = self.cm.getPage(linkUrl)
  2968. if not sts: return videoTab
  2969. data = self.cm.ph.getSearchGroups(data, """dataUrl[^'^"]*?:[^'^"]*?['"]([^'^"]+?)['"]""")[0]
  2970. if data.startswith("//"): linkUrl = "http:" + data
  2971. elif data.startswith("/"): linkUrl = "http://myvi.ru" + data
  2972. elif data.startswith("http"): linkUrl = data
  2973. else: return videoTab
  2974. sts, data = self.cm.getPage(linkUrl, params)
  2975. if not sts: return videoTab
  2976. try:
  2977. # get cookie data
  2978. universalUserID = self.cm.getCookieItem(COOKIE_FILE,'UniversalUserID')
  2979. data = json.loads(data)
  2980. for item in data['sprutoData']['playlist']:
  2981. url = item['video'][0]['url'].encode('utf-8')
  2982. if url.startswith('http'):
  2983. videoTab.append({'name': 'myvi.ru: %s' % item['duration'], 'url':strwithmeta(url, {'Cookie':'UniversalUserID=%s; vp=0.33' % universalUserID})})
  2984. except:
  2985. printExc()
  2986. return videoTab
  2987. def parserARCHIVEORG(self, linkUrl):
  2988. printDBG("parserARCHIVEORG linkUrl[%s]" % linkUrl)
  2989. videoTab = []
  2990. sts, data = self.cm.getPage(linkUrl)
  2991. if sts:
  2992. data = self.cm.ph.getSearchGroups(data, '"sources":\[([^]]+?)]')[0]
  2993. data = '[%s]' % data
  2994. try:
  2995. data = json.loads(data)
  2996. for item in data:
  2997. if 'mp4' == item['type']:
  2998. videoTab.append({'name':'archive.org: ' + item['label'].encode('utf-8'), 'url':'https://archive.org' + item['file'].encode('utf-8')})
  2999. except:
  3000. printExc()
  3001. return videoTab
  3002. def parserSAWLIVETV(self, baseUrl):
  3003. printDBG("parserSAWLIVETV linkUrl[%s]" % baseUrl)
  3004. HTTP_HEADER = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'}
  3005. baseUrl = urlparser.decorateParamsFromUrl(baseUrl)
  3006. Referer = baseUrl.meta.get('Referer', baseUrl)
  3007. #HTTP_HEADER['Referer'] = Referer
  3008. COOKIE_FILE = GetCookieDir('sawlive.tv')
  3009. params = {'header' : HTTP_HEADER, 'cookiefile':COOKIE_FILE, 'use_cookie': True, 'save_cookie':True, 'load_cookie':True}
  3010. stdWay = False
  3011. if 1:
  3012. sts, data = self.cm.getPage(baseUrl, {'header': HTTP_HEADER})
  3013. if not sts: return False
  3014. if 'eval' in data:
  3015. data = data.strip()
  3016. data = data[data.rfind('}(')+2:-2]
  3017. data = unpackJS(data, SAWLIVETV_decryptPlayerParams)
  3018. printDBG(">>>>>>>>>>>>>>>>>>>" + data)
  3019. def jal(a):
  3020. b = ''
  3021. for c in a:
  3022. b += JS_toString(ord(c), 16)
  3023. return b
  3024. linkUrl = self.cm.ph.getSearchGroups(data, '''src="([^"']+?)["']''')[0] + '/' + jal(urlparser().getHostName(Referer))
  3025. else:
  3026. stdWay = True
  3027. if stdWay:
  3028. params['header']['Referer'] = Referer
  3029. sts, data = self.cm.getPage(baseUrl, params)
  3030. if not sts: return False
  3031. vars = dict( re.compile("var ([^=]+?)='([^']+?)';").findall(data) )
  3032. data = self.cm.ph.getSearchGroups(data, 'src="([^"]+?)"')[0]
  3033. def fakeJSExec(dat):
  3034. dat = dat.group(1)
  3035. if dat.startswith('unescape'):
  3036. dat = self.cm.ph.getSearchGroups(dat, '\(([^)]+?)\)')[0]
  3037. if "'" == dat[0]:
  3038. dat = dat[1:-1]
  3039. else:
  3040. dat = vars[dat]
  3041. printDBG('dat: ' + dat)
  3042. return dat.replace('%', '\\u00').decode('unicode-escape').encode("utf-8")
  3043. else:
  3044. return vars[dat]
  3045. linkUrl = re.sub("'\+([^+]+?)\+'", fakeJSExec, data)
  3046. sts, data = self.cm.getPage(linkUrl, params)
  3047. if not sts: return False
  3048. swfUrl = self.cm.ph.getSearchGroups(data, "'(http[^']+?swf)'")[0]
  3049. url = self.cm.ph.getSearchGroups(data, "streamer'[^']+?'(rtmp[^']+?)'")[0]
  3050. file = self.cm.ph.getSearchGroups(data, "file'[^']+?'([^']+?)'")[0]
  3051. if '' != file and '' != url:
  3052. url += ' playpath=%s swfUrl=%s pageUrl=%s ' % (file, swfUrl, linkUrl)
  3053. #printDBG(url)
  3054. return url
  3055. return False
  3056. def parserSHIDURLIVECOM(self, baseUrl):
  3057. printDBG("parserSHIDURLIVECOM linkUrl[%s]" % baseUrl)
  3058. HTTP_HEADER = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3 Gecko/2008092417 Firefox/3.0.3', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'}
  3059. baseUrl = urlparser.decorateParamsFromUrl(baseUrl)
  3060. Referer = baseUrl.meta.get('Referer', baseUrl)
  3061. HTTP_HEADER['Referer'] = Referer
  3062. sts, data = self.cm.getPage(baseUrl, {'header': HTTP_HEADER})
  3063. if not sts: return False
  3064. linkUrl = self.cm.ph.getSearchGroups(data, 'src="(http[^"]+?)"')[0].strip()
  3065. sts, data = self.cm.getPage(linkUrl, {'header': HTTP_HEADER})
  3066. if not sts: return False
  3067. data = self.cm.ph.getDataBeetwenMarkers(data, 'new SWFObject', '</script>', True)[1]
  3068. printDBG(data)
  3069. dataTab = data.split(';')
  3070. data = ''
  3071. for line in dataTab:
  3072. if not line.strip().startswith('//'):
  3073. data += line+';'
  3074. swfUrl = self.cm.ph.getSearchGroups(data, "'(http[^']+?swf)'")[0]
  3075. url = self.cm.ph.getSearchGroups(data, "streamer'[^']+?'(rtmp[^']+?)'")[0]#.replace('rtmp://', 'rtmpe://')
  3076. file = urllib.unquote( self.cm.ph.getSearchGroups(data, "file'[^']+?'([^']+?)'")[0] )
  3077. if '' != file and '' != url:
  3078. url += ' playpath=%s swfUrl=%s pageUrl=%s live=1 ' % (file, swfUrl, linkUrl)
  3079. printDBG(url)
  3080. return url
  3081. return False
  3082. def parserCASTALBATV(self, baseUrl):
  3083. printDBG("parserCASTALBATV baseUrl[%s]" % baseUrl)
  3084. HTTP_HEADER = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3 Gecko/2008092417 Firefox/3.0.3', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'}
  3085. baseUrl = urlparser.decorateParamsFromUrl(baseUrl)
  3086. Referer = baseUrl.meta.get('Referer', baseUrl)
  3087. HTTP_HEADER['Referer'] = Referer
  3088. sts, data = self.cm.getPage(baseUrl, {'header': HTTP_HEADER})
  3089. if not sts: return False
  3090. def _getParam(name):
  3091. return self.cm.ph.getDataBeetwenMarkers(data, "'%s':" % name, ',', False)[1].strip() + ", '{0}'".format(name)
  3092. #self.cm.ph.getSearchGroups(data, """['"]%s['"][^'^"]+?['"]([^'^"]+?)['"]""" % name)[0]
  3093. def _getParamVal(value, name):
  3094. return value
  3095. data = self.cm.ph.getDataBeetwenMarkers(data, '<script type="text/javascript">', '</script>', False)[1]
  3096. vars = dict( re.compile('''var ([^=]+?)=[^']*?'([^']+?)['];''').findall(data) )
  3097. printDBG("===================================")
  3098. printDBG(vars)
  3099. printDBG("===================================")
  3100. addCode = ''
  3101. for item in vars:
  3102. addCode += '%s="%s"\n' % (item, vars[item])
  3103. funData = re.compile('function ([^\(]*?\([^\)]*?\))[^\{]*?\{([^\{]*?)\}').findall(data)
  3104. pyCode = addCode
  3105. for item in funData:
  3106. funHeader = item[0]
  3107. funBody = item[1]
  3108. funIns = funBody.split(';')
  3109. funBody = ''
  3110. for ins in funIns:
  3111. ins = ins.replace('var', ' ').strip()
  3112. funBody += '\t%s\n' % ins
  3113. if '' == funBody.replace('\t', '').replace('\n', '').strip():
  3114. continue
  3115. pyCode += 'def %s:' % funHeader.strip() + '\n' + funBody
  3116. addCode = pyCode
  3117. printDBG("===================================")
  3118. printDBG(pyCode)
  3119. printDBG("===================================")
  3120. swfUrl = unpackJS(_getParam('flashplayer'), _getParamVal, addCode)
  3121. url = unpackJS(_getParam('streamer'), _getParamVal, addCode)
  3122. file = unpackJS(_getParam('file'), _getParamVal, addCode)
  3123. if '' != file and '' != url:
  3124. url += ' playpath=%s swfUrl=%s pageUrl=%s live=1 ' % (file, swfUrl, baseUrl)
  3125. printDBG(url)
  3126. return url
  3127. return False
  3128. def parserFXSTREAMBIZ(self, baseUrl):
  3129. printDBG("parserFXSTREAMBIZ baseUrl[%s]" % baseUrl)
  3130. HTTP_HEADER = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3 Gecko/2008092417 Firefox/3.0.3', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'}
  3131. baseUrl = urlparser.decorateParamsFromUrl(baseUrl)
  3132. Referer = baseUrl.meta.get('Referer', '')
  3133. HTTP_HEADER['Referer'] = Referer
  3134. sts, data = self.cm.getPage(baseUrl, {'header': HTTP_HEADER})
  3135. if not sts: return False
  3136. def _getParam(name):
  3137. return self.cm.ph.getSearchGroups(data, """['"]*%s['"]*[^'^"]+?['"]([^'^"]+?)['"]""" % name)[0]
  3138. file = _getParam('file')
  3139. printDBG(data)
  3140. return False
  3141. def parserWEBCAMERAPL(self, baseUrl):
  3142. printDBG("parserWEBCAMERAPL baseUrl[%s]" % baseUrl)
  3143. sts, data = self.cm.getPage(baseUrl)
  3144. if sts:
  3145. data = self.cm.ph.getSearchGroups(data, """<meta itemprop="embedURL" content=['"]([^'^"]+?)['"]""")[0]
  3146. data = data.split('&')
  3147. if 2 < len(data) and data[0].startswith('http') and data[1].startswith('streamer=') and data[2].startswith('file='):
  3148. swfUrl = data[0]
  3149. url = urllib.unquote(data[1][len('streamer='):])
  3150. file = urllib.unquote(data[2][len('file='):])
  3151. if '' != file and '' != url:
  3152. url += ' playpath=%s swfUrl=%s pageUrl=%s live=1 ' % (file, swfUrl, baseUrl)
  3153. return url
  3154. else:
  3155. return False
  3156. def parserFLASHXTV(self, baseUrl):
  3157. printDBG("parserFLASHXTV baseUrl[%s]" % baseUrl)
  3158. HTTP_HEADER = { 'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0',
  3159. 'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  3160. 'Accept-Language':'pl,en-US;q=0.7,en;q=0.3',
  3161. 'Accept-Encoding':'gzip, deflate',
  3162. 'DNT':1,
  3163. 'Connection':'keep-alive',
  3164. }
  3165. HTTP_HEADER['Referer'] = baseUrl
  3166. SWF_URL = 'http://static.flashx.tv/player6/jwplayer.flash.swf'
  3167. COOKIE_FILE = GetCookieDir('flashxtv.cookie')
  3168. params = {'header':HTTP_HEADER, 'cookiefile':COOKIE_FILE, 'use_cookie': True, 'save_cookie':True, 'return_data':False}
  3169. sts, response = self.cm.getPage(baseUrl, params)
  3170. redirectUrl = response.geturl()
  3171. data = response.read()
  3172. params['header']['Referer'] = redirectUrl
  3173. params['return_data'] = True
  3174. params['load_cookie'] = True
  3175. def _first_of_each(*sequences):
  3176. return (next((x for x in sequence if x), '') for sequence in sequences)
  3177. def _url_path_join(*parts):
  3178. """Normalize url parts and join them with a slash."""
  3179. schemes, netlocs, paths, queries, fragments = zip(*(urlsplit(part) for part in parts))
  3180. scheme, netloc, query, fragment = _first_of_each(schemes, netlocs, queries, fragments)
  3181. path = '/'.join(x.strip('/') for x in paths if x)
  3182. return urlunsplit((scheme, netloc, path, query, fragment))
  3183. vid = self.cm.ph.getSearchGroups(redirectUrl+'/', '[^A-Za-z0-9]([A-Za-z0-9]{12})[^A-Za-z0-9]')[0]
  3184. if 'playthis-' in data:
  3185. play = 'playthis-'
  3186. else:
  3187. play = 'playit-'
  3188. url = self.cm.ph.getSearchGroups(redirectUrl, """(https?://[^/]+?/)""")[0] + play + '{0}.html'.format(vid)
  3189. sts, data = self.cm.getPage(url, params)
  3190. if not sts:
  3191. return False
  3192. post_data = None
  3193. if 'Proceed to video' in data:
  3194. sts, data = self.cm.ph.getDataBeetwenMarkers(data, '<Form method="POST"', '</Form>', True)
  3195. action = self.cm.ph.getSearchGroups(data, "action='([^']+?)'")[0]
  3196. post_data = dict(re.findall(r'<input[^>]*name="([^"]*)"[^>]*value="([^"]*)"[^>]*>', data))
  3197. try:
  3198. sleep_time = int(self.cm.ph.getSearchGroups(data, '>([0-9])</span> seconds<')[0])
  3199. time.sleep(sleep_time)
  3200. except:
  3201. printExc()
  3202. if {} == post_data:
  3203. post_data = None
  3204. if action.startswith('/'):
  3205. url = _url_path_join(url[:url.rfind('/')+1], action[1:])
  3206. else: url = action
  3207. sts, data = self.cm.getPage(url, params, post_data)
  3208. if not sts: return False
  3209. if 'fxplay' not in url and 'fxplay' in data:
  3210. url = self.cm.ph.getSearchGroups(data, '"(http[^"]+?fxplay[^"]+?)"')[0]
  3211. sts, data = self.cm.getPage(url)
  3212. if not sts: return False
  3213. try:
  3214. printDBG(data)
  3215. tmp = CParsingHelper.getDataBeetwenMarkers(data, ">eval(", '</script>')[1]
  3216. tmp = unpackJSPlayerParams(tmp, VIDUPME_decryptPlayerParams)
  3217. printDBG(tmp)
  3218. data = tmp + data
  3219. except:
  3220. printExc()
  3221. data = self.cm.ph.getSearchGroups(data, """["']*file["']*[ ]*?:[ ]*?["']([^"^']+?)['"]""")[0]
  3222. if data.startswith('http'):
  3223. if data.split('?')[0].endswith('.smil'):
  3224. # get stream link
  3225. sts, data = self.cm.getPage(data)
  3226. if sts:
  3227. base = self.cm.ph.getSearchGroups(data, 'base="([^"]+?)"')[0]
  3228. src = self.cm.ph.getSearchGroups(data, 'src="([^"]+?)"')[0]
  3229. #if ':' in src:
  3230. # src = src.split(':')[1]
  3231. if base.startswith('rtmp'):
  3232. return base + '/' + src + ' swfUrl=%s live=1 pageUrl=%s' % (SWF_URL, redirectUrl)
  3233. else:
  3234. return data
  3235. return False
  3236. def parserMYVIDEODE(self, baseUrl):
  3237. printDBG("parserMYVIDEODE baseUrl[%s]" % baseUrl)
  3238. HTTP_HEADER = {'User-Agent': "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:21.0) Gecko/20100101 Firefox/21.0",
  3239. 'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
  3240. 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  3241. 'Accept-Language': 'de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4',
  3242. 'Referer': baseUrl}
  3243. baseUrl = strwithmeta(baseUrl)
  3244. ################################################################################
  3245. # Implementation based on:
  3246. # https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/myvideo.py
  3247. ################################################################################
  3248. swfUrl = 'http://is5.myvideo.de/de/player/mingR14b/ming.swf'
  3249. GK = b'WXpnME1EZGhNRGhpTTJNM01XVmhOREU0WldNNVpHTTJOakptTW1FMU5tVTBNR05pWkRaa05XRXhNVFJoWVRVd1ptSXhaVEV3TnpsbA0KTVRkbU1tSTRNdz09'
  3250. requestParams = {'http_proxy':baseUrl.meta.get('http_proxy', '')}
  3251. requestParams['header'] = HTTP_HEADER
  3252. baseUrl = strwithmeta(baseUrl+'/')
  3253. videoTab = []
  3254. # Original Code from: https://github.com/dersphere/plugin.video.myvideo_de.git
  3255. # Released into the Public Domain by Tristan Fischer on 2013-05-19
  3256. # https://github.com/rg3/youtube-dl/pull/842
  3257. def __rc4crypt(data, key):
  3258. x = 0
  3259. box = list(range(256))
  3260. for i in list(range(256)):
  3261. x = (x + box[i] + ord(key[i % len(key)])) % 256
  3262. box[i], box[x] = box[x], box[i]
  3263. x = 0
  3264. y = 0
  3265. out = ''
  3266. for char in data:
  3267. x = (x + 1) % 256
  3268. y = (y + box[x]) % 256
  3269. box[x], box[y] = box[y], box[x]
  3270. out += chr(ord(char) ^ box[(box[x] + box[y]) % 256])
  3271. return out
  3272. def __md5(s):
  3273. return md5(s).hexdigest().encode()
  3274. def _getRtmpLink(r, tcUrl, playpath, swfUrl, page):
  3275. if '?token=' in r:
  3276. tmp = r.split('?token=')
  3277. r = tmp[0]
  3278. token = tmp[1]
  3279. else:
  3280. token = ''
  3281. if '' != tcUrl: r += ' tcUrl=' + tcUrl
  3282. if '' != playpath: r += ' playpath=' + playpath
  3283. if '' != swfUrl: r += ' swfUrl=' + swfUrl
  3284. if '' != page: r += ' pageUrl=' + page
  3285. if '' != token: r += ' token=' + token
  3286. return urlparser.decorateUrl(r, {'iptv_livestream':False})
  3287. # Get video ID
  3288. video_id = baseUrl
  3289. if '-m-' in video_id:
  3290. video_id = self.cm.ph.getSearchGroups(video_id, """-m-([0-9]+?)[^0-9]""")[0]
  3291. else:
  3292. video_id = self.cm.ph.getSearchGroups(video_id, """/(?:[^/]+/)?watch/([0-9]+)/""")[0]
  3293. if '' != video_id:
  3294. try:
  3295. xmldata_url = "http://www.myvideo.de/dynamic/get_player_video_xml.php?ID=%s&flash_playertype=D&autorun=yes" % video_id
  3296. sts, enc_data = self.cm.getPage(xmldata_url, requestParams)
  3297. enc_data = enc_data.split('=')[1]
  3298. enc_data_b = unhexlify(enc_data)
  3299. sk = __md5(base64.b64decode(base64.b64decode(GK)) + __md5(str(video_id).encode('utf-8')))
  3300. dec_data = __rc4crypt(enc_data_b, sk)
  3301. #printDBG("============================================================================")
  3302. #printDBG(dec_data)
  3303. #printDBG("============================================================================")
  3304. # extracting infos
  3305. connectionurl = urllib.unquote( self.cm.ph.getSearchGroups(dec_data, "connectionurl='([^']*?)'")[0] )
  3306. source = urllib.unquote( self.cm.ph.getSearchGroups(dec_data, "source='([^']*?)'")[0] )
  3307. path = urllib.unquote( self.cm.ph.getSearchGroups(dec_data, "path='([^']*?)'")[0] )
  3308. if connectionurl.startswith('rtmp'):
  3309. connectionurl = connectionurl.replace('rtmpe://', 'rtmp://')
  3310. rtmpUrl = urlparser.decorateUrl(connectionurl)
  3311. if rtmpUrl.meta.get('iptv_proto', '') == 'rtmp':
  3312. if not source.endswith('f4m') :
  3313. playpath = source.split('.')
  3314. playpath = '%s:%s' % (playpath[1], playpath[0])
  3315. videoUrl = _getRtmpLink(rtmpUrl, rtmpUrl, playpath, swfUrl, baseUrl)
  3316. videoTab.append({'name':'myvideo.de: RTMP', 'url':videoUrl})
  3317. else:
  3318. videoTab.append({'name':'myvideo.de: HTTP', 'url':path+source})
  3319. except:
  3320. printExc()
  3321. return videoTab
  3322. def parserVIDZITV(self, baseUrl):
  3323. printDBG("parserVIDZITV baseUrl[%s]" % baseUrl)
  3324. videoTab = []
  3325. if 'embed' not in baseUrl:
  3326. vid = self.cm.ph.getSearchGroups(baseUrl+'/', '[^A-Za-z0-9]([A-Za-z0-9]{12})[^A-Za-z0-9]')[0]
  3327. baseUrl = 'http://vidzi.tv/embed-%s-682x500.html' % vid
  3328. sts, data = self.cm.getPage(baseUrl)
  3329. if not sts: return False
  3330. # get JS player script code from confirmation page
  3331. sts, tmp = CParsingHelper.getDataBeetwenMarkers(data, ">eval(", '</script>', False)
  3332. if sts:
  3333. try:
  3334. tmp = unpackJSPlayerParams(tmp, VIDUPME_decryptPlayerParams)
  3335. data = tmp + data
  3336. except: printExc()
  3337. data = CParsingHelper.getDataBeetwenMarkers(data, 'sources:', ']', False)[1]
  3338. data = re.findall('file:[ ]*"([^"]+?)"', data)
  3339. for item in data:
  3340. if item.split('?')[0].endswith('m3u8'):
  3341. tmp = getDirectM3U8Playlist(item)
  3342. videoTab.extend(tmp)
  3343. else:
  3344. videoTab.append({'name':'vidzi.tv mp4', 'url':item})
  3345. return videoTab
  3346. def parserTVP(self, baseUrl):
  3347. printDBG("parserTVP baseUrl[%s]" % baseUrl)
  3348. vidTab = []
  3349. try:
  3350. sts, data = self.cm.getPage(baseUrl)
  3351. if sts:
  3352. object_id = self.cm.ph.getSearchGroups(data, 'data-video-id="([0-9]+?)"')[0]
  3353. if '' == object_id:
  3354. object_id = self.cm.ph.getSearchGroups(data, "object_id:'([0-9]+?)'")[0]
  3355. if '' == object_id:
  3356. object_id = self.cm.ph.getSearchGroups(data, 'object_id=([0-9]+?)[^0-9]')[0]
  3357. if '' != object_id:
  3358. from Plugins.Extensions.IPTVPlayer.hosts.hosttvpvod import TvpVod
  3359. vidTab = TvpVod().getVideoLink(object_id)
  3360. except:
  3361. printExc()
  3362. return vidTab
  3363. def parserJUNKYVIDEO(self, baseUrl):
  3364. printDBG("parserJUNKYVIDEO baseUrl[%s]" % baseUrl)
  3365. sts,data = self.cm.getPage(baseUrl)
  3366. if not sts: return []
  3367. url = self.cm.ph.getSearchGroups(data, r'''['"]?file['"]?[ ]*:[ ]*['"]([^"^']+)['"],''')[0]
  3368. if url.startswith('http'):
  3369. return [{'name':'junkyvideo.com', 'url':url}]
  3370. return []
  3371. def parserLIVEBVBTOTALDE(self, baseUrl):
  3372. printDBG("parserJUNKYVIDEO baseUrl[%s]" % baseUrl)
  3373. HTTP_HEADER = dict(self.HTTP_HEADER)
  3374. HTTP_HEADER['User-Agent'] = "Mozilla/5.0 (Linux; U; Android 4.1.1; en-us; androVM for VirtualBox ('Tablet' version with phone caps) Build/JRO03S) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30"
  3375. HTTP_HEADER['Referer'] = baseUrl
  3376. sts, data = self.cm.getPage(baseUrl, {'header':HTTP_HEADER})
  3377. if not sts: return []
  3378. data = self.cm.ph.getSearchGroups(data, r'<iframe[^>]+?src="([^"]+)"')[0]
  3379. sts, data = self.cm.getPage(data, {'header':HTTP_HEADER})
  3380. if not sts: return []
  3381. data = self.cm.ph.getSearchGroups(data, r'<iframe[^>]+?src="([^"]+)"')[0]
  3382. sts, data = self.cm.getPage(data, {'header':HTTP_HEADER})
  3383. if not sts: return []
  3384. data = self.cm.ph.getSearchGroups(data, r'url: "([^"]+)"')[0]
  3385. sts, data = self.cm.getPage(data, {'header':HTTP_HEADER})
  3386. if not sts: return []
  3387. printDBG(data)
  3388. if 'statustext="success"' not in data: return []
  3389. url = self.cm.ph.getSearchGroups(data, r'url="([^"]+)"')[0]
  3390. autch = self.cm.ph.getSearchGroups(data, r'auth="([^"]+)"')[0]
  3391. url += '?' + autch
  3392. linksTab = []
  3393. retTab = getDirectM3U8Playlist(url)
  3394. return retTab
  3395. for item in retTab:
  3396. name = ('live.bvbtotal.de %s' % item.get('heigth', 0))
  3397. url = urlparser.decorateUrl(item['url'], {'iptv_livestream': True})
  3398. linksTab.append({'name':name, 'url':url})
  3399. return linksTab
  3400. def parserNETTVPLUSCOM(self, baseUrl):
  3401. printDBG("parserNETTVPLUSCOM baseUrl[%s]" % baseUrl)
  3402. HTTP_HEADER = dict(self.HTTP_HEADER)
  3403. HTTP_HEADER['User-Agent'] = "Mozilla/5.0 (Linux; U; Android 4.1.1; en-us; androVM for VirtualBox ('Tablet' version with phone caps) Build/JRO03S) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30"
  3404. HTTP_HEADER['Referer'] = baseUrl
  3405. if baseUrl.endswith('/source.js'): url = baseUrl
  3406. else: url = baseUrl[:baseUrl.rfind('/')] + '/source.js'
  3407. sts, data = self.cm.getPage(url, {'header':HTTP_HEADER})
  3408. if not sts: return []
  3409. url = self.cm.ph.getSearchGroups(data, '''["'](http[^'^"]+?m3u8[^'^"]*?)["']''')[0]
  3410. if '' != url: return getDirectM3U8Playlist(url, False)
  3411. return []
  3412. def parser7CASTNET(self, baseUrl):
  3413. printDBG("parser7CASTNET baseUrl[%s]" % baseUrl)
  3414. baseUrl = urlparser.decorateUrl(baseUrl)
  3415. referer = baseUrl.meta.get('Referer', baseUrl)
  3416. HTTP_HEADER = dict(self.HTTP_HEADER)
  3417. HTTP_HEADER['User-Agent'] = "Mozilla/5.0 (Linux; U; Android 4.1.1; en-us; androVM for VirtualBox ('Tablet' version with phone caps) Build/JRO03S) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30"
  3418. HTTP_HEADER['Referer'] = referer
  3419. url = baseUrl
  3420. if '/embed/' in url:
  3421. sts, data = self.cm.getPage(url, {'header':HTTP_HEADER})
  3422. if not sts: return []
  3423. url = self.cm.ph.getSearchGroups(data, '''<iframe[^>]+?src=["'](http[^'^"]+?)["']''')[0]
  3424. sts, data = self.cm.getPage(url, {'header': HTTP_HEADER})
  3425. if not sts: return False
  3426. data = data[data.rfind('}(')+2:].split('{}))')[0] + '{}'
  3427. data = unpackJS(data, SAWLIVETV_decryptPlayerParams)
  3428. names = []
  3429. values = {}
  3430. data = re.compile(";([^;]+?)\.push\('(.)'\)").findall(data)
  3431. for item in data:
  3432. if item[0] not in names:
  3433. names.append(item[0])
  3434. values[item[0]] = item[1]
  3435. else: values[item[0]] += item[1]
  3436. if urllib.unquote(values[names[1]]).startswith('rtmp'): names = names[::-1]
  3437. r = urllib.unquote(values[names[0]]) + '/' + urllib.unquote(values[names[1]])
  3438. printDBG("...............................[%s]" % r)
  3439. if r.startswith('rtmp'):
  3440. swfUrl = "http://7cast.net/jplayer.swf"
  3441. rtmpUrl = r + ' swfUrl=%s pageUrl=%s live=1 ' % (swfUrl, baseUrl)
  3442. return [{'name': 'rtmp://7cast.com/ ', 'url':urlparser.decorateUrl(rtmpUrl, {'iptv_livestream':True})}]
  3443. return []
  3444. def parserFACEBOOK(self, baseUrl):
  3445. printDBG("parserFACEBOOK baseUrl[%s]" % baseUrl)
  3446. sts, data = self.cm.getPage(baseUrl)
  3447. if not sts: return []
  3448. # FROM: https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/facebook.py
  3449. BEFORE = '{swf.addParam(param[0], param[1]);});\n'
  3450. AFTER = '.forEach(function(variable) {swf.addVariable(variable[0], variable[1]);});'
  3451. m = self.cm.ph.getDataBeetwenMarkers(data, BEFORE, AFTER, False)[1]
  3452. data = dict(json.loads(m))
  3453. params_raw = urllib.unquote(data['params'])
  3454. params = byteify( json.loads(params_raw) )
  3455. urlsTab = []
  3456. for format_id, f in params['video_data'].items():
  3457. if not f or not isinstance(f, list):
  3458. continue
  3459. for quality in ('sd', 'hd'):
  3460. for src_type in ('src', 'src_no_ratelimit'):
  3461. src = f[0].get('%s_%s' % (quality, src_type))
  3462. if src:
  3463. urlsTab.append({'name':'facebook %s_%s_%s' % (format_id, quality, src_type), 'url':src})
  3464. return urlsTab
  3465. def parserCLOUDYVIDEOS(self, baseUrl):
  3466. printDBG("parserCLOUDYVIDEOS baseUrl[%s]" % baseUrl)
  3467. video_id = self.cm.ph.getSearchGroups(baseUrl+'/', '[/-]([A-Za-z0-9]{12})[/-]')[0]
  3468. url = 'http://cloudyvideos.com/{0}'.format(video_id)
  3469. linkList = []
  3470. HTTP_HEADER = dict(self.HTTP_HEADER)
  3471. HTTP_HEADER['Referer'] = baseUrl
  3472. sts, data = self.cm.getPage(baseUrl, {'header' : HTTP_HEADER})
  3473. try:
  3474. sleep_time = self.cm.ph.getSearchGroups(data, '>([0-9])</span> seconds<')[0]
  3475. if '' != sleep_time: time.sleep(int(sleep_time))
  3476. except:
  3477. printExc()
  3478. try:
  3479. sts, data = self.cm.ph.getDataBeetwenMarkers(data, 'method="POST"', '</Form>', False, False)
  3480. if not sts: return False
  3481. post_data = dict(re.findall(r'<input[^>]*name="([^"]*)"[^>]*value="([^"]*)"[^>]*>', data))
  3482. HTTP_HEADER['Referer'] = url
  3483. sts, data = self.cm.getPage(url, {'header' : HTTP_HEADER}, post_data)
  3484. if not sts: return False
  3485. #printDBG(data)
  3486. linkList = self._findLinks(data, serverName='cloudyvideos.com', m1='setup({', m2='</script>')
  3487. for item in linkList:
  3488. item['url'] = urlparser.decorateUrl(item['url']+'?start=0', {'User-Agent':'Mozilla/5.0', 'Referer':'http://cloudyvideos.com/player510/player.swf'})
  3489. except:
  3490. printExc()
  3491. return linkList
  3492. def parserFASTVIDEOIN(self, baseUrl):
  3493. printDBG("parserFASTVIDEOIN baseUrl[%s]" % baseUrl)
  3494. #http://fastvideo.in/nr4kzevlbuws
  3495. host = self.cm.ph.getDataBeetwenMarkers(baseUrl, "://", '/', False)[1]
  3496. video_id = self.cm.ph.getSearchGroups(baseUrl+'/', '[/-]([A-Za-z0-9]{12})[/-]')[0]
  3497. url = 'http://%s/embed-%s-960x480.html' % (host, video_id)
  3498. sts, data = self.cm.getPage(url)
  3499. if not sts: return False
  3500. return self._findLinks(data, host, m1='setup(', m2=')')
  3501. def parserTHEVIDEOME(self, baseUrl):
  3502. printDBG("parserTHEVIDEOME baseUrl[%s]" % baseUrl)
  3503. #http://thevideo.me/embed-l03p7if0va9a-682x500.html
  3504. if 'embed' in baseUrl: url = baseUrl
  3505. else: url = baseUrl.replace('.me/', '.me/embed-') + '-640x360.html'
  3506. sts, pageData = self.cm.getPage(url)
  3507. if not sts: return False
  3508. videoLinks = self._findLinks(pageData, 'thevideo.me', r'''['"]?file['"]?[ ]*:[ ]*['"](http[^"^']+)['"][,} ]''')
  3509. if len(videoLinks): return videoLinks
  3510. # get JS player script code from confirmation page
  3511. sts, data = CParsingHelper.getDataBeetwenMarkers(pageData, ">eval(", '</script>', False)
  3512. if sts:
  3513. mark1 = "}("
  3514. idx1 = data.find(mark1)
  3515. if -1 == idx1: return False
  3516. idx1 += len(mark1)
  3517. # unpack and decode params from JS player script code
  3518. pageData = unpackJS(data[idx1:-3], VIDUPME_decryptPlayerParams)
  3519. return self._findLinks(pageData, 'thevideo.me')
  3520. else:
  3521. pageData = CParsingHelper.getDataBeetwenMarkers(pageData, 'setup(', '</script', False)[1]
  3522. videoUrl = self.cm.ph.getSearchGroups(pageData, r"""['"]?file['"]?[ ]*?\:[ ]*?['"]([^"^']+?)['"]""")[0]
  3523. if videoUrl.startswith('http'): return urlparser.decorateUrl(videoUrl)
  3524. return False
  3525. def parserMODIVXCOM(self, baseUrl):
  3526. printDBG("parserMODIVXCOM baseUrl[%s]" % baseUrl)
  3527. serverName='movdivx.com'
  3528. def __customLinksFinder(pageData):
  3529. #printDBG(pageData)
  3530. sts, data = CParsingHelper.getDataBeetwenMarkers(pageData, ">eval(", '</script>', False)
  3531. if sts:
  3532. mark1 = "}("
  3533. idx1 = data.find(mark1)
  3534. if -1 == idx1: return False
  3535. idx1 += len(mark1)
  3536. pageData = unpackJS(data[idx1:-3], VIDUPME_decryptPlayerParams)
  3537. return self._findLinks(pageData, serverName)
  3538. else: return []
  3539. return self.__parseJWPLAYER_A(baseUrl, serverName, customLinksFinder=__customLinksFinder)
  3540. def parserXAGEPL(self, baseUrl):
  3541. printDBG("parserXAGEPL baseUrl[%s]" % baseUrl)
  3542. sts, data = self.cm.getPage(baseUrl)
  3543. if not sts: return False
  3544. url = self.cm.ph.getSearchGroups(data, 'src="([^"]+?)"')[0]
  3545. return urlparser().getVideoLinkExt(url)
  3546. def parseCASTONTV(self, baseUrl):
  3547. printDBG("parseCASTONTV baseUrl[%s]" % baseUrl)
  3548. baseUrl = urlparser.decorateParamsFromUrl(baseUrl)
  3549. Referer = baseUrl.meta.get('Referer', '')
  3550. HTTP_HEADER = dict({'User-Agent':'Mozilla/5.0'})
  3551. HTTP_HEADER['Referer'] = Referer
  3552. COOKIE_FILE = GetCookieDir('castontv.cookie')
  3553. params = {'header':HTTP_HEADER, 'cookiefile':COOKIE_FILE, 'use_cookie': True, 'save_cookie':True}
  3554. id = self.cm.ph.getSearchGroups(baseUrl + '|', 'id=([0-9]+?)[^0-9]')[0]
  3555. linkUrl = 'http://www.caston.tv/player.php?width=1920&height=419&id={0}'.format(id)
  3556. sts, data = self.cm.getPage(linkUrl, params)
  3557. if not sts: return False
  3558. data = re.sub('''unescape\(["']([^"^']+?)['"]\)''', lambda m: urllib.unquote(m.group(1)), data)
  3559. #printDBG(data)
  3560. tmpData = self.cm.ph.getDataBeetwenMarkers(data, "eval(", '</script>', True)[1]
  3561. printDBG(tmpData)
  3562. while 'eval' in tmpData:
  3563. tmp = tmpData.split('eval(')
  3564. if len(tmp): del tmp[0]
  3565. tmpData = ''
  3566. for item in tmp:
  3567. for decFun in [VIDEOWEED_decryptPlayerParams, SAWLIVETV_decryptPlayerParams]:
  3568. tmpData = unpackJSPlayerParams('eval('+item, decFun, 0)
  3569. if '' != tmpData:
  3570. break
  3571. printDBG("ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ")
  3572. printDBG(tmpData)
  3573. printDBG("ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ")
  3574. if 'token' in tmpData and 'm3u8' in tmpData:
  3575. break
  3576. token = self.cm.ph.getSearchGroups(tmpData, r"""['"]?token['"]?[\s]*?\:[\s]*?['"]([^"^']+?)['"]""")[0]
  3577. url = self.cm.ph.getSearchGroups(tmpData, r"""['"]?url['"]?[\s]*?\:[\s]*?['"]([^"^']+?)['"]""")[0]
  3578. file = self.cm.ph.getSearchGroups(tmpData, r"""['"]?file['"]?[\s]*?\:[\s]*?['"]([^}]+?)\}""")[0]
  3579. printDBG("token[%s]" % token)
  3580. printDBG("url[%s]" % url)
  3581. printDBG("file[%s]" % file)
  3582. if url != '' and '://' not in url:
  3583. if url.startswith('//'): url = 'http:' + url
  3584. else: url = 'http://www.caston.tv/' + url
  3585. params['load_cookie'] = True
  3586. params['header'].update({'Referer':linkUrl, 'Accept':'application/json, text/javascript, */*', 'Content-Type':'application/x-www-form-urlencoded', 'X-Requested-With':'XMLHttpRequest' })
  3587. sts, data = self.cm.getPage(url, params, {'token':token, 'is_ajax':1})
  3588. if not sts: return False
  3589. data = byteify(json.loads(data))
  3590. printDBG(data)
  3591. def _replace(item):
  3592. idx = int(item.group(1))
  3593. return str(data[idx])
  3594. file = re.sub('"\+[^"]+?\[([0-9]+?)\]\+"', _replace, file+'+"')
  3595. hlsUrl = urlparser.decorateUrl(file, {'iptv_proto':'m3u8', 'iptv_livestream':True, 'Referer':'http://p.jwpcdn.com/6/12/jwplayer.flash.swf', 'User-Agent':'Mozilla/5.0'})
  3596. return getDirectM3U8Playlist(hlsUrl)
  3597. def parserCASTAMPCOM(self, baseUrl):
  3598. printDBG("parserCASTAMPCOM baseUrl[%s]" % baseUrl)
  3599. channel = self.cm.ph.getSearchGroups(baseUrl + '&', 'c=([^&]+?)&')[0]
  3600. baseUrl = urlparser.decorateParamsFromUrl(baseUrl)
  3601. Referer = baseUrl.meta.get('Referer', '')
  3602. HTTP_HEADER = dict(self.HTTP_HEADER)
  3603. HTTP_HEADER['Referer'] = Referer
  3604. def _getDomainsa():
  3605. chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"
  3606. string_length = 8
  3607. randomstring = ''
  3608. for i in range(string_length):
  3609. rnum = randint(0, len(chars)-1)
  3610. randomstring += chars[rnum]
  3611. return randomstring
  3612. linkUrl = 'http://www.castamp.com/embed.php?c={0}&tk={1}&vwidth=710&vheight=460'.format(channel, _getDomainsa())
  3613. sts, data = self.cm.getPage(linkUrl, {'header':HTTP_HEADER})
  3614. if not sts: return False
  3615. sts, data = CParsingHelper.getDataBeetwenMarkers(data, '<div id="player">', '</script>', False)
  3616. if not sts: return False
  3617. data = re.sub("<!--[\s\S]*?-->", "", data)
  3618. data = re.sub("/\*[\s\S]*?\*/", "", data)
  3619. def _getParam(name):
  3620. return self.cm.ph.getSearchGroups(data, """['"]%s['"][^'^"]+?['"]([^'^"]+?)['"]""" % name)[0]
  3621. swfUrl = _getParam('flashplayer')
  3622. url = _getParam('streamer')
  3623. file = _getParam('file')
  3624. if '' != file and '' != url:
  3625. url += ' playpath=%s swfUrl=%s pageUrl=%s live=1 ' % (file, swfUrl, baseUrl)
  3626. printDBG(url)
  3627. return url
  3628. return False
  3629. def parserCRICHDTV(self, baseUrl):
  3630. printDBG("parserCRICHDTV baseUrl[%s]" % baseUrl)
  3631. baseUrl = urlparser.decorateParamsFromUrl(baseUrl)
  3632. Referer = baseUrl.meta.get('Referer', '')
  3633. HTTP_HEADER = dict(self.HTTP_HEADER)
  3634. HTTP_HEADER['Referer'] = Referer
  3635. sts, data = self.cm.getPage(baseUrl, {'header':HTTP_HEADER})
  3636. if not sts: return False
  3637. baseUrl.meta['Referer'] = baseUrl
  3638. links = urlparser().getAutoDetectedStreamLink(baseUrl, data)
  3639. return links
  3640. channelId = self.cm.ph.getSearchGroups(data, "id='([0-9]+?)'")[0]
  3641. linkUrl = 'http://popeoftheplayers.eu/crichd.php?id={0}&width=710&height=460'.format(channelId)
  3642. HTTP_HEADER['Referer'] = baseUrl
  3643. sts, data = self.cm.getPage(linkUrl, {'header':HTTP_HEADER})
  3644. if not sts: return False
  3645. data = re.sub("<!--[\s\S]*?-->", "", data)
  3646. data = re.sub("/\*[\s\S]*?\*/", "", data)
  3647. def _getParam(name):
  3648. return self.cm.ph.getSearchGroups(data, """['"]%s['"][^'^"]+?['"]([^'^"]+?)['"]""" % name)[0]
  3649. swfUrl = "http://popeoftheplayers.eu/atdedead.swf"#_getParam('flashplayer')
  3650. url = _getParam('streamer') #rtmp://89.248.172.159:443/liverepeater
  3651. file = _getParam('file')
  3652. if '' != file and '' != url:
  3653. url += ' playpath=%s swfUrl=%s token=%s pageUrl=%s live=1 ' % (file, swfUrl, '#atd%#$ZH', linkUrl)
  3654. printDBG(url)
  3655. return url
  3656. return False
  3657. def parserCASTTOME(self, baseUrl):
  3658. printDBG("parserCASTTOME baseUrl[%s]" % baseUrl)
  3659. baseUrl = urlparser.decorateParamsFromUrl(baseUrl)
  3660. Referer = baseUrl.meta.get('Referer', '')
  3661. HTTP_HEADER = dict(self.HTTP_HEADER)
  3662. HTTP_HEADER['Referer'] = Referer
  3663. sts, data = self.cm.getPage(baseUrl, {'header':HTTP_HEADER})
  3664. if not sts: return False
  3665. data = re.sub("<!--[\s\S]*?-->", "", data)
  3666. data = re.sub("/\*[\s\S]*?\*/", "", data)
  3667. def _getParam(name):
  3668. return self.cm.ph.getSearchGroups(data, """['"]%s['"][^'^"]+?['"]([^'^"]+?)['"]""" % name)[0]
  3669. swfUrl = "http://www.castto.me/_.swf"
  3670. url = _getParam('streamer')
  3671. file = _getParam('file')
  3672. if '' != file and '' != url:
  3673. url += ' playpath=%s swfUrl=%s token=%s pageUrl=%s live=1 ' % (file, swfUrl, '#ed%h0#w@1', baseUrl)
  3674. printDBG(url)
  3675. return url
  3676. return False
  3677. def _unpackJS(self, data, name):
  3678. data = data.replace('Math.min', 'min').replace(' + (', ' + str(').replace('String.fromCharCode', 'chr').replace('return b[a]', 'return saveGet(b, a)')
  3679. def saveGet(b, a):
  3680. try:
  3681. return b[a]
  3682. except:
  3683. return 'pic'
  3684. def justRet(data):
  3685. return data
  3686. try:
  3687. paramsAlgoObj = compile(data, '', 'exec')
  3688. except:
  3689. printExc('unpackJS compile algo code EXCEPTION')
  3690. return ''
  3691. vGlobals = {"__builtins__": None, 'string': string, 'str':str, 'chr':chr, 'decodeURIComponent':urllib.unquote, 'unescape':urllib.unquote, 'min':min, 'saveGet':saveGet, 'justRet':justRet}
  3692. vLocals = { name: None }
  3693. try:
  3694. exec( data, vGlobals, vLocals )
  3695. except:
  3696. printExc('unpackJS exec code EXCEPTION')
  3697. return ''
  3698. try:
  3699. return vLocals[name]
  3700. except:
  3701. printExc('decryptPlayerParams EXCEPTION')
  3702. return ''
  3703. def parserHDCASTINFO(self, baseUrl):
  3704. printDBG("parserHDCASTINFO baseUrl[%s]" % baseUrl)
  3705. return self.parserCAST4UTV(baseUrl, 'hdcast.info')
  3706. def parserCAST4UTV(self, baseUrl, domain='cast4u.tv'):
  3707. printDBG("parserCAST4UTV baseUrl[%s]" % baseUrl)
  3708. def _getVariables(data):
  3709. printDBG('_getVariables')
  3710. varTabs = []
  3711. tmp = re.compile('var([^;]+?)=[^;]*?(\[[^\]]+?\]);').findall(data)
  3712. for item in tmp:
  3713. var = item[0].strip()
  3714. val = item[1].strip()
  3715. if var == '': continue
  3716. if val == '': continue
  3717. varTabs.append('%s = %s' % (var, val))
  3718. varTabs = '\n'.join( varTabs )
  3719. return varTabs
  3720. baseUrl = urlparser.decorateParamsFromUrl(baseUrl)
  3721. Referer = baseUrl.meta.get('Referer', '')
  3722. HTTP_HEADER = dict(self.HTTP_HEADER)
  3723. HTTP_HEADER['Referer'] = Referer
  3724. sts, data = self.cm.getPage(baseUrl, {'header':HTTP_HEADER})
  3725. if not sts: return False
  3726. data = re.sub("<!--[\s\S]*?-->", "", data)
  3727. data = re.sub("/\*[\s\S]*?\*/", "", data)
  3728. data = self.cm.ph.getDataBeetwenMarkers(data, '<span style', '</script>')[1]
  3729. globalVars = _getVariables(data)
  3730. file = self.cm.ph.getDataBeetwenMarkers(data, 'file:', '}', False)[1].strip()
  3731. token = self.cm.ph.getSearchGroups(data, """securetoken\s*:\s*([^\s]+?)\s""")[0]
  3732. def _evalSimple(dat):
  3733. return '"%s"' % self.cm.ph.getSearchGroups(data, """<[^>]+?id=['"]?%s['"]?[^>]*?>([^<]+?)<""" % dat.group(1))[0]
  3734. data = re.sub('document\.getElementById\("([^"]+?)"\)\.innerHTML', _evalSimple, data)
  3735. def _evalJoin(dat):
  3736. return " ''.join(%s) " % dat.group(1)
  3737. funData = re.compile('function ([^\(]*?\([^\)]*?\))[^\{]*?\{([^\{]*?)\}').findall(data)
  3738. pyCode = ''
  3739. for item in funData:
  3740. funHeader = item[0]
  3741. funBody = re.sub('(\[[^\]]+?\])\.join\(""\)', _evalJoin, item[1])
  3742. funBody = re.sub(' ([^ ]+?)\.join\(""\)', _evalJoin, funBody)
  3743. funIns = funBody.split(';')
  3744. funBody = ''
  3745. for ins in funIns:
  3746. ins = ins.replace('var', ' ').strip()
  3747. if len(ins) and ins[-1] not in [')', ']', '"']:
  3748. ins += '()'
  3749. funBody += '\t%s\n' % ins
  3750. if '' == funBody.replace('\t', '').replace('\n', '').strip():
  3751. continue
  3752. pyCode += 'def %s:' % funHeader.strip() + '\n' + funBody
  3753. pyCode = 'def retA():\n\t' + globalVars.replace('\n', '\n\t') + '\n\t' + pyCode.replace('\n', '\n\t') + '\n\treturn {0}\n'.format(file) + 'param = retA()'
  3754. printDBG(pyCode)
  3755. file = self._unpackJS(pyCode, 'param').replace('\\/', '/')
  3756. swfUrl = 'http://%s/jwplayer/jwplayer.flash.swf' % domain
  3757. token = '%XB00(nKH@#.' #http://stream-recorder.com/forum/rtmp-token-vlc-help-t20959.html?s=7c3a16e350bdc8bdf73c525163884654&amp;
  3758. return file + ' swfUrl=%s token=%s pageUrl=%s live=1 ' % (swfUrl, token, baseUrl)
  3759. def parserDELTATVPW(self, baseUrl):
  3760. printDBG("parserDELTATVPW baseUrl[%s]" % baseUrl)
  3761. baseUrl = urlparser.decorateParamsFromUrl(baseUrl)
  3762. Referer = baseUrl.meta.get('Referer', '')
  3763. HTTP_HEADER = dict(self.HTTP_HEADER)
  3764. HTTP_HEADER['Referer'] = Referer
  3765. sts, data = self.cm.getPage(baseUrl, {'header':HTTP_HEADER})
  3766. if not sts: return False
  3767. data = re.sub("<!--[\s\S]*?-->", "", data)
  3768. data = re.sub("/\*[\s\S]*?\*/", "", data)
  3769. def _getParam(name):
  3770. return self.cm.ph.getSearchGroups(data, "%s=([^&]+?)&" % name)[0]
  3771. swfUrl = "http://cdn.deltatv.pw/players.swf"
  3772. url = _getParam('streamer')
  3773. file = _getParam('file')
  3774. if '' != file and '' != url:
  3775. url += ' playpath=%s swfUrl=%s token=%s pageUrl=%s live=1 ' % (file, swfUrl, 'Fo5_n0w?U.rA6l3-70w47ch', baseUrl)
  3776. printDBG(url)
  3777. return url
  3778. return False
  3779. def parserPXSTREAMTV(self, baseUrl):
  3780. printDBG("parserPXSTREAMTV baseUrl[%s]" % baseUrl)
  3781. baseUrl = urlparser.decorateParamsFromUrl(baseUrl)
  3782. Referer = baseUrl.meta.get('Referer', '')
  3783. HTTP_HEADER = dict(self.HTTP_HEADER)
  3784. HTTP_HEADER['Referer'] = Referer
  3785. sts, data = self.cm.getPage(baseUrl, {'header':HTTP_HEADER})
  3786. if not sts: return False
  3787. data = re.sub("<!--[\s\S]*?-->", "", data)
  3788. data = re.sub("/\*[\s\S]*?\*/", "", data)
  3789. def _getParam(name):
  3790. return self.cm.ph.getSearchGroups(data, """%s:[^'^"]*?['"]([^'^"]+?)['"]""" % name)[0]
  3791. swfUrl = "http://pxstream.tv/player510.swf"
  3792. url = _getParam('streamer')
  3793. file = _getParam('file')
  3794. if file.split('?')[0].endswith('.m3u8'):
  3795. return getDirectM3U8Playlist(file)
  3796. elif '' != file and '' != url:
  3797. url += ' playpath=%s swfUrl=%s pageUrl=%s live=1 ' % (file, swfUrl, baseUrl)
  3798. printDBG(url)
  3799. return url
  3800. return False
  3801. def parserCOOLCASTEU(self, baseUrl):
  3802. printDBG("parserCOOLCASTEU baseUrl[%s]" % baseUrl)
  3803. baseUrl = urlparser.decorateParamsFromUrl(baseUrl)
  3804. Referer = baseUrl.meta.get('Referer', '')
  3805. HTTP_HEADER = dict(self.HTTP_HEADER)
  3806. HTTP_HEADER['Referer'] = Referer
  3807. sts, data = self.cm.getPage(baseUrl, {'header':HTTP_HEADER})
  3808. if not sts: return False
  3809. data = re.sub("<!--[\s\S]*?-->", "", data)
  3810. data = re.sub("/\*[\s\S]*?\*/", "", data)
  3811. printDBG(data)
  3812. def _getParam(name):
  3813. return self.cm.ph.getSearchGroups(data, """['"]%s['"]:[^'^"]*?['"]([^'^"]+?)['"]""" % name)[0]
  3814. swfUrl = "http://coolcast.eu/file/1444766476/player.swf"
  3815. url = _getParam('streamer')
  3816. file = _getParam('file')
  3817. if '' != file and '' != url:
  3818. url += ' playpath=%s swfVfy=%s pageUrl=%s live=1 ' % (file, swfUrl, baseUrl)
  3819. printDBG(url)
  3820. return url
  3821. return False
  3822. def parserFILENUKE(self, baseUrl):
  3823. printDBG("parserFILENUKE baseUrl[%s]" % baseUrl)
  3824. HTTP_HEADER= { 'User-Agent':'Mozilla/5.0' }
  3825. COOKIE_FILE = GetCookieDir('filenuke.com')
  3826. params_s = {'header':HTTP_HEADER, 'cookiefile':COOKIE_FILE, 'use_cookie': True, 'save_cookie':True}
  3827. params_l = {'header':HTTP_HEADER, 'cookiefile':COOKIE_FILE, 'use_cookie': True, 'load_cookie':True}
  3828. params_s['return_data'] = False
  3829. sts, response = self.cm.getPage(baseUrl, params_s)
  3830. redirectUrl = response.geturl()
  3831. data = response.read()
  3832. if not sts: return False
  3833. if 'method_free' in data:
  3834. sts, data = self.cm.getPage(baseUrl, params_l, {'method_free':'Free'})
  3835. if not sts: return False
  3836. if 'id="go-next"' in data:
  3837. url = self.cm.ph.getSearchGroups(data, '<a[^>]+?id="go-next"[^>]+?href="([^"]+?)"')[0]
  3838. baseUrl = self.cm.ph.getSearchGroups(redirectUrl, '(https?://[^/]+?)/')[0]
  3839. if url.startswith('/'): url = baseUrl + url
  3840. sts, data = self.cm.getPage(url, params_l)
  3841. if not sts: return False
  3842. data = self.cm.ph.getDataBeetwenMarkers(data, 'jwplayer', 'play(')[1]
  3843. printDBG(data)
  3844. videoMarker = self.cm.ph.getSearchGroups(data, r"""['"]?file['"]?[ ]*?:[ ]*?([^ ^,]+?),""")[0]
  3845. videoUrl = self.cm.ph.getSearchGroups(data, r"""['"]?%s['"]?[ ]*?\=[ ]*?['"](http[^'^"]+?)["']""" % videoMarker)[0]
  3846. printDBG("parserFILENUKE videoMarker[%s] videoUrl[%s]" % (videoMarker, videoUrl))
  3847. if '' == videoUrl: return False
  3848. videoUrl = urlparser.decorateUrl(videoUrl, {'User-Agent':'Mozilla/5.0', 'Referer':'http://filenuke.com/a/jwplayer/jwplayer.flash.swf'})
  3849. return videoUrl
  3850. def parserTHEFILEME(self, baseUrl):
  3851. printDBG("parserTHEFILEME baseUrl[%s]" % baseUrl)
  3852. HTTP_HEADER= { 'User-Agent':"Mozilla/5.0 (Linux; U; Android 4.1.1; en-us; androVM for VirtualBox ('Tablet' version with phone caps) Build/JRO03S) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30" }
  3853. COOKIE_FILE = GetCookieDir('thefile.me')
  3854. params_s = {'header':HTTP_HEADER, 'cookiefile':COOKIE_FILE, 'use_cookie': True, 'save_cookie':True}
  3855. params_l = {'header':HTTP_HEADER, 'cookiefile':COOKIE_FILE, 'use_cookie': True, 'load_cookie':True}
  3856. sts, data = self.cm.getPage(baseUrl, params_s)
  3857. if not sts: return False
  3858. data = CParsingHelper.getDataBeetwenMarkers(data, '<div class="main-wrap">', '</script>', False)[1]
  3859. videoUrl = self.cm.ph.getSearchGroups(data, r"""['"]?%s['"]?[ ]*?\=[ ]*?['"](http[^'^"]+?)["']""" % 'href')[0]
  3860. seconds = self.cm.ph.getSearchGroups(data, r"""seconds[ ]*?\=[ ]*?([^;^ ]+?);""")[0]
  3861. printDBG("parserFILENUKE seconds[%s] videoUrl[%s]" % (seconds, videoUrl))
  3862. seconds = int(seconds)
  3863. time.sleep(seconds+1)
  3864. params_l['header']['Referer'] = videoUrl
  3865. sts, data = self.cm.getPage(videoUrl, params_l)
  3866. if not sts: return False
  3867. data = CParsingHelper.getDataBeetwenMarkers(data, 'setup({', '}', False)[1]
  3868. videoUrl = self.cm.ph.getSearchGroups(data, r"""['"]?file['"]?[ ]*?\:[ ]*?['"]([^"^']+?)['"]""")[0]
  3869. if videoUrl.startswith('http'): return urlparser.decorateUrl(videoUrl)
  3870. return False
  3871. def parserCLOUDTIME(self, baseUrl):
  3872. printDBG("parserCLOUDTIME baseUrl[%s]" % baseUrl)
  3873. HTTP_HEADER= { 'User-Agent':"Mozilla/5.0" }
  3874. COOKIE_FILE = GetCookieDir('cloudtime.to')
  3875. params_s = {'header':HTTP_HEADER, 'cookiefile':COOKIE_FILE, 'use_cookie': True, 'save_cookie':True}
  3876. params_l = {'header':HTTP_HEADER, 'cookiefile':COOKIE_FILE, 'use_cookie': True, 'load_cookie':True}
  3877. if 'embed.' not in baseUrl:
  3878. baseUrl = 'http://www.cloudtime.to/embed.php?v=' + self.cm.ph.getSearchGroups(baseUrl + '/', '/video/([^/]+?)/')[0]
  3879. sts, data = self.cm.getPage(baseUrl, params_s)
  3880. if not sts: return False
  3881. params = {}
  3882. params['filekey'] = self.cm.ph.getSearchGroups(data, 'flashvars.filekey=([^;]+?);')[0]
  3883. params['file'] = self.cm.ph.getSearchGroups(data, 'flashvars.file=([^;]+?);')[0]
  3884. for key in params:
  3885. ok = False
  3886. for m in ['"', "'"]:
  3887. if params[key].startswith(m) and params[key].endswith(m):
  3888. params[key] = params[key][1:-1]
  3889. ok = True
  3890. break
  3891. if not ok:
  3892. params[key] = self.cm.ph.getSearchGroups(data, r'''var %s=['"]([^'^"]+?)['"]''' % params[key])[0]
  3893. videoUrl = "http://www.cloudtime.to/api/player.api.php?pass=undefined&key={0}&file={1}&user=undefined&cid3=undefined&cid=undefined&numOfErrors=0&cid2=undefined".format(urllib.quote(params['filekey']), urllib.quote(params['file']))
  3894. sts, data = self.cm.getPage(videoUrl, params_l)
  3895. if not sts: return False
  3896. videoUrl = CParsingHelper.getDataBeetwenMarkers(data, 'url=', '&', False)[1]
  3897. if videoUrl.startswith('http'): return urlparser.decorateUrl(videoUrl+'?client=FLASH')
  3898. return False
  3899. def parserNOSVIDEO(self, baseUrl):
  3900. printDBG("parserNOSVIDEO baseUrl[%s]" % baseUrl)
  3901. # code from https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/nosvideo.py
  3902. HTTP_HEADER= { 'User-Agent':"Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10", 'Referer':baseUrl }
  3903. _VALID_URL = r'https?://(?:www\.)?nosvideo\.com/' + \
  3904. '(?:embed/|\?v=)(?P<id>[A-Za-z0-9]{12})/?'
  3905. _PLAYLIST_URL = 'http://nosvideo.com/xml/{0}.xml'
  3906. try:
  3907. mobj = re.match(_VALID_URL, baseUrl)
  3908. video_id = mobj.group('id')
  3909. post_data = {
  3910. 'id': video_id,
  3911. 'op': 'download1',
  3912. 'method_free': 'Continue to Video',
  3913. }
  3914. sts, data = self.cm.getPage(baseUrl, {'header':HTTP_HEADER}, post_data)
  3915. if not sts: return False
  3916. id = self.cm.ph.getSearchGroups(data, 'php\|([^\|]+)\|')[0]
  3917. url = _PLAYLIST_URL.format(id)
  3918. sts, data = self.cm.getPage(url, {'header':HTTP_HEADER})
  3919. if not sts: return False
  3920. videoUrl = CParsingHelper.getDataBeetwenMarkers(data, '<file>', '</file>', False)[1]
  3921. except:
  3922. videoUrl = ''
  3923. pass
  3924. if '' == videoUrl:
  3925. printDBG(">>>> [%s]" % baseUrl)
  3926. video_id = self.cm.ph.getSearchGroups(baseUrl+'/', '[^A-F^a-f^0-9]([A-Fa-f0-9]{16})[^A-F^a-f^0-9]')[0]
  3927. if '' == video_id:
  3928. url = baseUrl
  3929. else:
  3930. url = 'http://nosvideo.com/vj/video.php?u=%s&w=640&h=380' % video_id
  3931. sts, data = self.cm.getPage(url)
  3932. if not sts: return False
  3933. videoUrl = self.cm.ph.getSearchGroups(data, '''tracker:[^'^"]*?['"]([^'^"]+?)['"]''')[0]
  3934. videoUrl = base64.b64decode(videoUrl)
  3935. if videoUrl.startswith('http'):
  3936. return urlparser.decorateUrl(videoUrl)
  3937. return False
  3938. def parserPUTSTREAM(self, baseUrl):
  3939. printDBG("parserPUTSTREAM baseUrl[%s]" % baseUrl)
  3940. def _findLinks(data):
  3941. return self._findLinks(data, 'putstream.com')
  3942. return self._parserUNIVERSAL_A(baseUrl, 'http://putstream.com/embed-{0}-640x400.html', _findLinks)
  3943. def parserLETWATCHUS(self, baseUrl):
  3944. printDBG("parserLETWATCHUS baseUrl[%s]" % baseUrl)
  3945. def _findLinks(data):
  3946. return self._findLinks(data, 'letwatch.us')
  3947. return self._parserUNIVERSAL_A(baseUrl, 'http://letwatch.us/embed-{0}-640x360.html', _findLinks)
  3948. def parserUPLOADCCOM(self, baseUrl):
  3949. printDBG("parserUPLOADCCOM baseUrl[%s]" % baseUrl)
  3950. def _findLinks(data):
  3951. return self._findLinks2(data, baseUrl)
  3952. return self._parserUNIVERSAL_A(baseUrl, 'http://www.uploadc.com/embed-{0}.html', _findLinks)
  3953. def parserMIGHTYUPLOAD(self, baseUrl):
  3954. printDBG("parserMIGHTYUPLOAD baseUrl[%s]" % baseUrl)
  3955. def _preProcessing(data):
  3956. return CParsingHelper.getDataBeetwenMarkers(data, '<div id="player_code">', '</div>', False)[1]
  3957. def _findLinks(data):
  3958. return self._findLinks2(data, baseUrl)
  3959. return self._parserUNIVERSAL_A(baseUrl, 'http://www.mightyupload.com/embed-{0}-645x353.html', _findLinks, _preProcessing)
  3960. def parserZALAACOM(self, baseUrl):
  3961. printDBG("parserZALAACOM baseUrl[%s]" % baseUrl)
  3962. def _findLinks(data):
  3963. return self._findLinks2(data, baseUrl)
  3964. return self._parserUNIVERSAL_A(baseUrl, 'http://www.zalaa.com/embed-{0}.html', _findLinks)
  3965. def parserALLMYVIDEOS(self, baseUrl):
  3966. printDBG("parserALLMYVIDEOS baseUrl[%s]" % baseUrl)
  3967. def _findLinks(data):
  3968. return self._findLinks(data, 'allmyvideos.net')
  3969. return self._parserUNIVERSAL_A(baseUrl, 'http://allmyvideos.net/embed-{0}.html', _findLinks)
  3970. def parserRAPIDVIDEOWS(self, baseUrl):
  3971. printDBG("parserRAPIDVIDEOWS baseUrl[%s]" % baseUrl)
  3972. def _findLinks(data):
  3973. return self._findLinks2(data, baseUrl)
  3974. return self._parserUNIVERSAL_A(baseUrl, 'http://rapidvideo.ws/embed-{0}-720x420.html', _findLinks)
  3975. def parserHDVIDTV(self, baseUrl):
  3976. printDBG("parserHDVIDTV baseUrl[%s]" % baseUrl)
  3977. def _findLinks(data):
  3978. return self._findLinks2(data, baseUrl)
  3979. return self._parserUNIVERSAL_A(baseUrl, 'http://hdvid.tv/embed-{0}-950x480.html', _findLinks)
  3980. def parseVIDME(self, baseUrl):
  3981. printDBG("parseVIDME baseUrl[%s]" % baseUrl)
  3982. # from: https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/vidme.py
  3983. _VALID_URL = r'https?://vid\.me/(?:e/)?(?P<id>[\da-zA-Z]{,5})(?:[^\da-zA-Z]|$)'
  3984. mobj = re.match(_VALID_URL, baseUrl)
  3985. id = mobj.group('id')
  3986. sts, data = self.cm.getPage('https://api.vid.me/videoByUrl/' + id)
  3987. if not sts: return False
  3988. data = byteify( json.loads(data) )['video']
  3989. if 'formats' in data:
  3990. urlTab = []
  3991. for item in data['formats']:
  3992. if '-clip' in item['type']: continue
  3993. try:
  3994. if item['type'] == 'dash': continue
  3995. elif item['type'] == 'hls':
  3996. continue
  3997. hlsTab = getDirectM3U8Playlist(item['uri'], False)
  3998. urlTab.extend(hlsTab)
  3999. else:
  4000. urlTab.append({'name':item['type'], 'url':item['uri']})
  4001. except: pass
  4002. return urlTab
  4003. else:
  4004. return urlparser().getVideoLinkExt(data['source'])
  4005. return False
  4006. def parseVEEHDCOM(self, baseUrl):
  4007. printDBG("parseVEEHDCOM baseUrl[%s]" % baseUrl)
  4008. COOKIE_FILE = GetCookieDir('veehdcom.cookie')
  4009. HTTP_HEADER= { 'User-Agent':'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/37.0.2062.120 Chrome/37.0.2062.120 Safari/537.36',
  4010. 'Referer':baseUrl}
  4011. params = {'header':HTTP_HEADER, 'cookiefile':COOKIE_FILE, 'use_cookie': True, 'save_cookie':True}
  4012. sts, data = self.cm.getPage(baseUrl, params)
  4013. if not sts: return False
  4014. data = self.cm.ph.getDataBeetwenMarkers(data, 'playeriframe', ';', False)[1]
  4015. url = self.cm.ph.getSearchGroups(data, '''src[ ]*?:[ ]*?['"]([^"^']+?)['"]''')[0]
  4016. if not url.startswith('http'):
  4017. if not url.startswith('/'):
  4018. url = '/' + url
  4019. url = 'http://veehd.com' + url
  4020. sts, data = self.cm.getPage(url, params)
  4021. if not sts: return False
  4022. vidUrl = self.cm.ph.getSearchGroups(data, '''type=['"]video[^"^']*?["'][^>]+?src=["']([^'^"]+?)['"]''')[0]
  4023. if vidUrl.startswith('http'):
  4024. return vidUrl
  4025. return False
  4026. def parseSHAREREPOCOM(self, baseUrl):
  4027. printDBG("parseSHAREREPOCOM baseUrl[%s]" % baseUrl)
  4028. HTTP_HEADER= { 'User-Agent':'Mozilla/5.0'}
  4029. sts, data = self.cm.getPage(baseUrl, {'header':HTTP_HEADER})
  4030. tab = []
  4031. tmp = self._findLinks(data, m1='setup', m2='</script>')
  4032. for item in tmp:
  4033. item['url'] = urlparser.decorateUrl(item['url'], {'Referer':baseUrl, 'User-Agent':'Mozilla/5.0'})
  4034. tab.append(item)
  4035. return tab
  4036. def parseEASYVIDEOME(self, baseUrl):
  4037. printDBG("parseEASYVIDEOME baseUrl[%s]" % baseUrl)
  4038. HTTP_HEADER= { 'User-Agent':'Mozilla/5.0'}
  4039. sts, data = self.cm.getPage(baseUrl, {'header':HTTP_HEADER})
  4040. if not sts: return False
  4041. data = self.cm.ph.getDataBeetwenMarkers(data, '<div id="flowplayer">', '</script>', False)[1]
  4042. tab = self._findLinks(data, serverName='playlist', linkMarker=r'''['"]?url['"]?[ ]*:[ ]*['"](http[^"^']+)['"][,}]''', m1='playlist', m2=']')
  4043. video_url = self.cm.ph.getSearchGroups(data, '_url = "(http[^"]+?)"')[0]
  4044. if '' != video_url:
  4045. video_url = urllib.unquote(video_url)
  4046. tab.insert(0, {'name':'main', 'url':video_url})
  4047. return tab
  4048. def parseUPTOSTREAMCOM(self, baseUrl):
  4049. printDBG("parseUPTOSTREAMCOM baseUrl[%s]" % baseUrl)
  4050. if 'iframe' not in baseUrl:
  4051. video_id = self.cm.ph.getSearchGroups(baseUrl+'/', '/([A-Za-z0-9]{12})[/.]')[0]
  4052. url = 'https://uptostream.com/iframe/' + video_id
  4053. else:
  4054. url = baseUrl
  4055. sts, data = self.cm.getPage(url)
  4056. if not sts: return False
  4057. #'<font color="red">', '</font>'
  4058. urlTab = []
  4059. data = self.cm.ph.getAllItemsBeetwenMarkers(data, '<source ', '>', False, False)
  4060. for item in data:
  4061. type = self.cm.ph.getSearchGroups(item, '''type=['"]([^"^']+?)['"]''')[0]
  4062. res = self.cm.ph.getSearchGroups(item, '''res=['"]([^"^']+?)['"]''')[0]
  4063. lang = self.cm.ph.getSearchGroups(item, '''lang=['"]([^"^']+?)['"]''')[0]
  4064. url = self.cm.ph.getSearchGroups(item, '''src=['"]([^"^']+?)['"]''')[0]
  4065. if url.startswith('//'):
  4066. url = 'http:' + url
  4067. if url.startswith('http'):
  4068. urlTab.append({'name':'uptostream {0}: {1}'.format(lang, res), 'url':url})
  4069. return urlTab
  4070. def parseVIMEOCOM(self, baseUrl):
  4071. printDBG("parseVIMEOCOM baseUrl[%s]" % baseUrl)
  4072. if 'player' not in baseUrl:
  4073. video_id = self.cm.ph.getSearchGroups(baseUrl+'/', '/([0-9]+?)[/.]')[0]
  4074. url = 'https://player.vimeo.com/video/' + video_id
  4075. else:
  4076. url = baseUrl
  4077. sts, data = self.cm.getPage(url)
  4078. if not sts: return False
  4079. urlTab = []
  4080. tmp = self.cm.ph.getDataBeetwenMarkers(data, 'progressive', ']', False)[1]
  4081. tmp = tmp.split('}')
  4082. printDBG(tmp)
  4083. for item in tmp:
  4084. if 'video/mp4' not in item: continue
  4085. quality = self.cm.ph.getSearchGroups(item, '''quality['"]?:['"]([^"^']+?)['"]''')[0]
  4086. url = self.cm.ph.getSearchGroups(item, '''url['"]?:['"]([^"^']+?)['"]''')[0]
  4087. if url.startswith('http'):
  4088. urlTab.append({'name':'vimeo.com {0}'.format(quality), 'url':url})
  4089. hlsUrl = self.cm.ph.getSearchGroups(data, '"hls"[^}]+?"url"\:"([^"]+?)"')[0]
  4090. tab = getDirectM3U8Playlist(hlsUrl)
  4091. urlTab.extend(tab)
  4092. return urlTab
  4093. def parseJACVIDEOCOM(self, baseUrl):
  4094. printDBG("parseJACVIDEOCOM baseUrl[%s]" % baseUrl)
  4095. HTTP_HEADER= { 'User-Agent':"Mozilla/5.0", 'Referer':baseUrl }
  4096. params = {'header':HTTP_HEADER, 'use_cookie': True, 'load_cookie': True, 'save_cookie': True, 'cookiefile': GetCookieDir('jacvideocom.cookie')}
  4097. sts, data = self.cm.getPage(baseUrl, params)
  4098. if not sts: return False
  4099. tmp = self.cm.ph.getDataBeetwenMarkers(data, 'jacvideosys(', ');', False)[1]
  4100. tmp = data.split(',')[-1]
  4101. link = self.cm.ph.getSearchGroups(tmp, '''link['"]?:['"]([^"^']+?)['"]''')[0]
  4102. if link != '':
  4103. post_data = {'link':link}
  4104. sts, data = self.cm.getPage('http://www.jacvideo.com/embed/plugins/jacvideosys.php', params, post_data)
  4105. if not sts: return False
  4106. try:
  4107. data = byteify(json.loads(data))
  4108. if 'error' in data:
  4109. SetIPTVPlayerLastHostError(data['error'])
  4110. linksTab = []
  4111. for item in data['link']:
  4112. if item['type'] != 'mp4': continue
  4113. url = item['link']
  4114. name = item['label']
  4115. url = urlparser.decorateUrl(url, {'iptv_livestream':False, 'User-Agent':HTTP_HEADER['User-Agent'], 'Referer':baseUrl})
  4116. linksTab.append({'name':name, 'url':url})
  4117. return linksTab
  4118. except:
  4119. printExc()
  4120. return self._findLinks(data, contain='mp4')
  4121. def parseSPEEDVICEONET(self, baseUrl):
  4122. printDBG("parseSPEEDVICEONET baseUrl[%s]" % baseUrl)
  4123. if 'embed' not in baseUrl:
  4124. video_id = self.cm.ph.getSearchGroups(baseUrl+'/', '/([A-Za-z0-9]{12})[/.]')[0]
  4125. url = 'http://speedvideo.net/embed-{0}-600x360.html'.format(video_id)
  4126. else:
  4127. url = baseUrl
  4128. sts, data = self.cm.getPage(url)
  4129. if not sts: return False
  4130. urlTab = []
  4131. tmp = []
  4132. for item in [('linkfile', 'normal'), ('linkfileBackup', 'backup'), ('linkfileBackupLq', 'low')]:
  4133. try:
  4134. a = re.compile('var\s+linkfile *= *"(.+?)"').findall(data)[0]
  4135. b = re.compile('var\s+linkfile *= *base64_decode\(.+?\s+(.+?)\)').findall(data)[0]
  4136. c = re.compile('var\s+%s *= *(\d*)' % b).findall(data)[0]
  4137. vidUrl = a[:int(c)] + a[(int(c) + 10):]
  4138. vidUrl = base64.b64decode(vidUrl)
  4139. if vidUrl not in tmp:
  4140. tmp.append(vidUrl)
  4141. if vidUrl.split('?')[0].endswith('.m3u8'):
  4142. tab = getDirectM3U8Playlist(vidUrl)
  4143. urlTab.extend(tab)
  4144. else:
  4145. urlTab.append({'name':item[1], 'url':vidUrl})
  4146. except:
  4147. continue
  4148. return urlTab
  4149. def parseXVIDSTAGECOM(self, baseUrl):
  4150. printDBG("parseXVIDSTAGECOM baseUrl[%s]" % baseUrl)
  4151. sts, data = self.cm.getPage(baseUrl)
  4152. if not sts: return False
  4153. def _first_of_each(*sequences):
  4154. return (next((x for x in sequence if x), '') for sequence in sequences)
  4155. def _url_path_join(*parts):
  4156. """Normalize url parts and join them with a slash."""
  4157. schemes, netlocs, paths, queries, fragments = zip(*(urlsplit(part) for part in parts))
  4158. scheme, netloc, query, fragment = _first_of_each(schemes, netlocs, queries, fragments)
  4159. path = '/'.join(x.strip('/') for x in paths if x)
  4160. return urlunsplit((scheme, netloc, path, query, fragment))
  4161. sts, data = self.cm.ph.getDataBeetwenMarkers(data.split('site_logo')[-1], '<Form method="POST"', '</Form>', True)
  4162. action = self.cm.ph.getSearchGroups(data, "action='([^']+?)'")[0]
  4163. post_data = dict(re.findall(r'<input[^>]*name="([^"]*)"[^>]*value="([^"]*)"[^>]*>', data))
  4164. try:
  4165. sleep_time = int(self.cm.ph.getSearchGroups(data, '>([0-9])</span> seconds<')[0])
  4166. time.sleep(sleep_time)
  4167. except:
  4168. printExc()
  4169. if {} == post_data:
  4170. post_data = None
  4171. if action.startswith('/'):
  4172. url = _url_path_join(url[:url.rfind('/')+1], action[1:])
  4173. else: url = action
  4174. if url == '':
  4175. url = baseUrl
  4176. sts, data = self.cm.getPage(url, {}, post_data)
  4177. if not sts: return False
  4178. try:
  4179. tmp = CParsingHelper.getDataBeetwenMarkers(data.split('player_code')[-1], ">eval(", '</script>')[1]
  4180. tmp = unpackJSPlayerParams(tmp, VIDUPME_decryptPlayerParams)
  4181. data = tmp + data
  4182. except:
  4183. pass
  4184. videoUrl = self.cm.ph.getSearchGroups(data, '<[^>]+?type="video[^>]+?src="([^"]+?)"')[0]
  4185. if videoUrl.startswith('http'):
  4186. return videoUrl
  4187. return False
  4188. def parserSTREAMPLAYCC(self, baseUrl):
  4189. printDBG("parserSTREAMPLAYCC baseUrl[%s]" % baseUrl)
  4190. HTTP_HEADER= { 'User-Agent':"Mozilla/5.0", 'Referer':baseUrl }
  4191. if '/embed/' not in baseUrl:
  4192. video_id = self.cm.ph.getSearchGroups(baseUrl+'/', '/([A-Za-z0-9]{16})/')[0]
  4193. url = 'http://www.streamplay.cc/embed/{0}'.format(video_id)
  4194. else:
  4195. url = baseUrl
  4196. post_data = None
  4197. sts, data = self.cm.getPage(url, {'header':HTTP_HEADER}, post_data)
  4198. if not sts: return False
  4199. data = CParsingHelper.getDataBeetwenMarkers(data, 'id="playerStream"', '</a>', False)[1]
  4200. videoUrl = self.cm.ph.getSearchGroups(data, 'href="(http[^"]+?)"')[0]
  4201. if '' != videoUrl: return videoUrl
  4202. return False
  4203. def parserYOURVIDEOHOST(self, baseUrl):
  4204. printDBG("parserSTREAMPLAYCC baseUrl[%s]" % baseUrl)
  4205. video_id = self.cm.ph.getSearchGroups(baseUrl+'/', '[^A-Za-z0-9]([A-Za-z0-9]{12})[^A-Za-z0-9]')[0]
  4206. url = 'http://yourvideohost.com/{0}'.format(video_id)
  4207. return self.__parseJWPLAYER_A(url, 'yourvideohost.com')
  4208. def parserVIDGGTO(self, baseUrl):
  4209. printDBG("parserVIDGGTO baseUrl[%s]" % baseUrl)
  4210. return self._parserUNIVERSAL_B(baseUrl)
  4211. def parserTINYCC(self, baseUrl):
  4212. printDBG("parserTINYCC baseUrl[%s]" % baseUrl)
  4213. query_data = { 'url': baseUrl, 'return_data': False }
  4214. response = self.cm.getURLRequestData(query_data)
  4215. redirectUrl = response.geturl()
  4216. response.close()
  4217. if baseUrl != redirectUrl:
  4218. return urlparser().getVideoLinkExt(redirectUrl)
  4219. return False
  4220. def parserWHOLECLOUD(self, baseUrl):
  4221. printDBG("parserWHOLECLOUD baseUrl[%s]" % baseUrl)
  4222. #url = baseUrl.replace('movshare.net', 'wholecloud.net')
  4223. try:
  4224. mobj = re.search(r'/(?:file|video)/(?P<id>[a-z\d]{13})', baseUrl)
  4225. video_id = mobj.group('id')
  4226. url = 'http://www.wholecloud.net/embed/?v=' + video_id
  4227. except:
  4228. printExc()
  4229. return self._parserUNIVERSAL_B(url)
  4230. def parserSTREAM4KTO(self, baseUrl):
  4231. printDBG("parserSTREAM4KTO baseUrl[%s]" % baseUrl)
  4232. sts, data = self.cm.getPage(baseUrl)
  4233. if not sts: return False
  4234. mainData = data
  4235. data = self.cm.ph.getSearchGroups(data, "drdX_fx\('([^']+?)'\)")[0]
  4236. data = drdX_fx( data )
  4237. data = self.cm.ph.getSearchGroups(data, 'proxy.link=linkcdn%2A([^"]+?)"')[0]
  4238. printDBG(data)
  4239. if data != '':
  4240. x = gledajfilmDecrypter(198,128)
  4241. Key = "VERTR05uak80NEpDajY1ejJjSjY="
  4242. data = x.decrypt(data, Key.decode('base64', 'strict'), "ECB")
  4243. if '' != data:
  4244. return urlparser().getVideoLinkExt(data)
  4245. data = unpackJSPlayerParams(mainData, SAWLIVETV_decryptPlayerParams, 0)
  4246. printDBG(">>>>>>>>>>>>>>>>>>>" + data)
  4247. return self._findLinks(data)
  4248. def parserONETTV(self, baseUrl):
  4249. printDBG("parserONETTV baseUrl[%r]" % baseUrl )
  4250. videoUrls = []
  4251. sts, data = self.cm.getPage(baseUrl)
  4252. if not sts: return videoUrls
  4253. ckmId = self.cm.ph.getSearchGroups(data, 'data-params-mvp="([^"]+?)"')[0]
  4254. if '' == ckmId: ckmId = self.cm.ph.getSearchGroups(data, 'id="mvp:([^"]+?)"')[0]
  4255. if '' == ckmId: return videoUrls
  4256. tm = str(int(time.time() * 1000))
  4257. jQ = str(randrange(562674473039806,962674473039806))
  4258. authKey = 'FDF9406DE81BE0B573142F380CFA6043'
  4259. hostName = urlparser().getHostName(baseUrl)
  4260. contentUrl = 'http://qi.ckm.onetapi.pl/?callback=jQuery183040'+ jQ + '_' + tm + '&body%5Bid%5D=' + authKey + '&body%5Bjsonrpc%5D=2.0&body%5Bmethod%5D=get_asset_detail&body%5Bparams%5D%5BID_Publikacji%5D=' + ckmId + '&body%5Bparams%5D%5BService%5D={0}&content-type=application%2Fjsonp&x-onet-app=player.front.onetapi.pl&_='.format(hostName) + tm
  4261. sts, data = self.cm.getPage(contentUrl)
  4262. if sts:
  4263. try:
  4264. printDBG(data)
  4265. data = byteify( json.loads(data[data.find("(")+1:-2]) )
  4266. data = data['result']['0']['formats']['wideo']
  4267. for type in data:
  4268. for vidItem in data[type]:
  4269. if None != vidItem.get('drm_key', None): continue
  4270. vidUrl = vidItem.get('url', '')
  4271. if '' == vidUrl: continue
  4272. if 'hls' == type:
  4273. tmpTab = getDirectM3U8Playlist(vidUrl)
  4274. for tmp in tmpTab:
  4275. videoUrls.append({'name':'ONET type:%s :%s' % (type, tmp.get('bitrate', '0')), 'url':tmp['url']})
  4276. elif None != vidItem.get('video_bitrate', None):
  4277. videoUrls.append({'name':'ONET type:%s :%s' % (type, vidItem.get('video_bitrate', '0')), 'url':vidUrl})
  4278. elif None != vidItem.get('audio_bitrate', None):
  4279. videoUrls.append({'name':'ONET type:%s :%s' % (type, vidItem.get('audio_bitrate', '0')), 'url':vidUrl})
  4280. except:
  4281. printExc()
  4282. return videoUrls
  4283. def paserBYETVORG(self, baseUrl):
  4284. printDBG("paserBYETVORG baseUrl[%r]" % baseUrl )
  4285. HTTP_HEADER= { 'User-Agent':"Mozilla/5.0", 'Referer':baseUrl.meta.get('Referer', baseUrl) }
  4286. file = self.cm.ph.getSearchGroups(baseUrl, "file=([0-9]+?)[^0-9]")[0]
  4287. if '' == file: file = self.cm.ph.getSearchGroups(baseUrl, "a=([0-9]+?)[^0-9]")[0]
  4288. linkUrl = "http://www.byetv.org/embed.php?a={0}&id=&width=710&height=460&autostart=true&strech=".format(file)
  4289. sts, data = self.cm.getPage(linkUrl, {'header':HTTP_HEADER})
  4290. if not sts: return False
  4291. sts, data = CParsingHelper.getDataBeetwenMarkers(data, '"jwplayer1"', '</script>', False)
  4292. if not sts: return False
  4293. def _getParam(name):
  4294. return self.cm.ph.getSearchGroups(data, "'%s',[ ]*?'([^']+?)'" % name)[0]
  4295. swfUrl = "http://p.jwpcdn.com/6/8/jwplayer.flash.swf"
  4296. streamer = _getParam('streamer')
  4297. file = _getParam('file')
  4298. token = _getParam('token')
  4299. provider = _getParam('provider')
  4300. rtmpUrl = provider + streamer[streamer.find(':'):]
  4301. if '' != file and '' != rtmpUrl:
  4302. rtmpUrl += ' playpath=file:%s swfUrl=%s token=%s pageUrl=%s live=1 ' % (file, swfUrl, token, linkUrl)
  4303. printDBG(rtmpUrl)
  4304. return rtmpUrl
  4305. return False
  4306. def paserPUTLIVEIN(self, baseUrl):
  4307. printDBG("paserPUTLIVEIN baseUrl[%r]" % baseUrl )
  4308. HTTP_HEADER= { 'User-Agent':"Mozilla/5.0", 'Referer':baseUrl.meta.get('Referer', baseUrl) }
  4309. file = self.cm.ph.getSearchGroups(baseUrl, "file=([0-9]+?)[^0-9]")[0]
  4310. if '' == file: file = self.cm.ph.getSearchGroups(baseUrl+'/', "/e/([^/]+?)/")[0]
  4311. linkUrl = "http://www.putlive.in/e/{0}".format(file)
  4312. sts, data = self.cm.getPage(linkUrl, {'header':HTTP_HEADER})
  4313. if not sts: return False
  4314. #printDBG("=======================================================")
  4315. #printDBG(data)
  4316. #printDBG("=======================================================")
  4317. token = self.cm.ph.getSearchGroups(data, "'key' : '([^']+?)'")[0]
  4318. if token != "": token = ' token=%s ' % token
  4319. sts, data = CParsingHelper.getDataBeetwenMarkers(data, 'unescape("', '")', False)
  4320. if not sts: return False
  4321. data = urllib.unquote(data)
  4322. #printDBG(data)
  4323. def _getParam(name):
  4324. return self.cm.ph.getSearchGroups(data, "%s=([^&]+?)&" % name)[0]
  4325. swfUrl = "http://putlive.in/player59.swf"
  4326. streamer = _getParam('streamer')
  4327. file = _getParam('file')
  4328. provider = _getParam('provider')
  4329. rtmpUrl = provider + streamer[streamer.find(':'):]
  4330. if '' != file and '' != rtmpUrl:
  4331. rtmpUrl += ' playpath=%s swfUrl=%s %s pageUrl=%s live=1 ' % (file, swfUrl, token, linkUrl)
  4332. printDBG(rtmpUrl)
  4333. return rtmpUrl
  4334. return False
  4335. def paserSTREAMLIVETO(self, baseUrl):
  4336. printDBG("paserSTREAMLIVETO baseUrl[%r]" % baseUrl )
  4337. HTTP_HEADER= { 'User-Agent':"Mozilla/5.0", 'Referer':baseUrl.meta.get('Referer', baseUrl) }
  4338. defaultParams = {'header':HTTP_HEADER, 'use_cookie': True, 'load_cookie': True, 'save_cookie': True, 'cookiefile': GetCookieDir('streamliveto.cookie')}
  4339. _url_re = re.compile("http(s)?://(\w+\.)?(ilive.to|streamlive.to)/.*/(?P<channel>\d+)")
  4340. channel = _url_re.match(baseUrl).group("channel")
  4341. linksTab = []
  4342. # get link for mobile
  4343. linkUrl ='http://www.streamlive.to/view/%s' % channel
  4344. if 1:
  4345. userAgent = 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10'
  4346. params = dict(defaultParams)
  4347. params.update({'header':{'User-Agent':userAgent}})
  4348. sts, data = self.cm.getPage(linkUrl, params)
  4349. if sts:
  4350. # hls
  4351. hlsUrl = self.cm.ph.getSearchGroups(data, '''['"](http[^"']+?\.m3u8[^"']*?)["']''')[0]
  4352. if hlsUrl != '':
  4353. hlsUrl = urlparser.decorateUrl(hlsUrl, {'iptv_proto':'m3u8', 'iptv_livestream':True, 'User-Agent':userAgent})
  4354. linksTab.extend( getDirectM3U8Playlist(hlsUrl) )
  4355. if 'You have reached the limit today.' in data:
  4356. SetIPTVPlayerLastHostError(_('No free credits.'))
  4357. params = dict(defaultParams)
  4358. params.update({'header':{'header':HTTP_HEADER}})
  4359. sts, data = self.cm.getPage(linkUrl, params)
  4360. if not sts: return False
  4361. if '<div id="loginbox">' in data:
  4362. SetIPTVPlayerLastHostError(_("Only logged in user have access.\nPlease set login data in the host configuration under blue button."))
  4363. if 'get_free_credits' in data:
  4364. msg = clean_html(self.cm.ph.getDataBeetwenMarkers(data, '<div id="player_container">', '</a>')[1])
  4365. if msg != '':
  4366. SetIPTVPlayerLastHostError(msg)
  4367. # get token
  4368. token = CParsingHelper.getDataBeetwenMarkers(data, 'var token', '});', False)[1]
  4369. token = self.cm.ph.getSearchGroups(token, '"([^"]+?/server.php[^"]+?)"')[0]
  4370. if token.startswith('//'): token = 'http:' + token
  4371. params = dict(defaultParams)
  4372. params.update({'header':{'header':HTTP_HEADER}})
  4373. sts, token = self.cm.getPage(token, params)
  4374. if not sts: return False
  4375. token = byteify(json.loads(token))['token']
  4376. if token != "": token = ' token=%s ' % token
  4377. # get others params
  4378. data = CParsingHelper.getDataBeetwenMarkers(data, '.setup(', '</script>', False)[1]
  4379. def _getParam(name):
  4380. return self.cm.ph.getSearchGroups(data, """['"]*%s['"]*[^'^"]+?['"]([^'^"]+?)['"]""" % name)[0].replace('\\/', '/')
  4381. swfUrl = "http://www.streamlive.to/player/ilive-plugin.swf"
  4382. streamer = _getParam('streamer')
  4383. file = _getParam('file').replace('.flv', '')
  4384. app = 'edge/' + streamer.split('/edge/')[-1]
  4385. provider = _getParam('provider')
  4386. rtmpUrl = provider + streamer[streamer.find(':'):]
  4387. if rtmpUrl.startswith('video://'):
  4388. linksTab.append({'name':'http', 'url': rtmpUrl.replace('video://', 'http://')})
  4389. elif '' != file and '' != rtmpUrl:
  4390. rtmpUrl += ' playpath=%s swfUrl=%s %s pageUrl=%s app=%s live=1 ' % (file, swfUrl, token, linkUrl, app)
  4391. printDBG(rtmpUrl)
  4392. linksTab.append({'name':'rtmp', 'url': rtmpUrl})
  4393. return linksTab
  4394. def paserMEGOMTV(self, baseUrl):
  4395. printDBG("paserMEGOMTV baseUrl[%r]" % baseUrl )
  4396. HTTP_HEADER= { 'User-Agent':"Mozilla/5.0", 'Referer':baseUrl.meta.get('Referer', baseUrl) }
  4397. id = self.cm.ph.getSearchGroups(baseUrl, "id=([^&]+?)&")[0]
  4398. linkUrl = "http://distro.megom.tv/player-inside.php?id={0}&width=100%&height=450".format(id)
  4399. sts, data = self.cm.getPage(linkUrl, {'header':HTTP_HEADER})
  4400. if not sts: return False
  4401. sts, data = CParsingHelper.getDataBeetwenMarkers(data, '<head>', 'var ad_data;', False)
  4402. if not sts: return False
  4403. swfUrl = 'http://lds.megom.tv/jwplayer.flash.swf'
  4404. a = int(self.cm.ph.getSearchGroups(data, 'var a = ([0-9]+?);')[0])
  4405. b = int(self.cm.ph.getSearchGroups(data, 'var b = ([0-9]+?);')[0])
  4406. c = int(self.cm.ph.getSearchGroups(data, 'var c = ([0-9]+?);')[0])
  4407. d = int(self.cm.ph.getSearchGroups(data, 'var d = ([0-9]+?);')[0])
  4408. f = int(self.cm.ph.getSearchGroups(data, 'var f = ([0-9]+?);')[0])
  4409. v_part = self.cm.ph.getSearchGroups(data, "var v_part = '([^']+?)'")[0]
  4410. rtmpUrl = ('rtmp://%d.%d.%d.%d' % (a/f, b/f, c/f, d/f) ) + v_part
  4411. rtmpUrl += ' swfUrl=%s pageUrl=%s live=1 ' % (swfUrl, linkUrl)
  4412. printDBG(rtmpUrl)
  4413. return rtmpUrl
  4414. def parserOPENLOADIO(self, baseUrl):
  4415. printDBG("parserOPENLOADIO baseUrl[%r]" % baseUrl )
  4416. HTTP_HEADER= { 'User-Agent':"Mozilla/5.0", 'Referer':baseUrl}
  4417. HTTP_HEADER = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11',
  4418. 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  4419. 'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
  4420. 'Accept-Encoding': 'none',
  4421. 'Accept-Language': 'en-US,en;q=0.8',
  4422. 'Referer':baseUrl} #'Connection': 'keep-alive'
  4423. sts, data = self.cm.getPage(baseUrl, {'header':HTTP_HEADER})
  4424. if not sts: return False
  4425. subTracksData = self.cm.ph.getAllItemsBeetwenMarkers(data, '<track ', '>', False, False)
  4426. subTracks = []
  4427. for track in subTracksData:
  4428. if 'kind="captions"' not in track: continue
  4429. subUrl = self.cm.ph.getSearchGroups(track, 'src="([^"]+?)"')[0]
  4430. if subUrl.startswith('/'):
  4431. subUrl = 'http://openload.co' + subUrl
  4432. if subUrl.startswith('http'):
  4433. subLang = self.cm.ph.getSearchGroups(track, 'srclang="([^"]+?)"')[0]
  4434. subLabel = self.cm.ph.getSearchGroups(track, 'label="([^"]+?)"')[0]
  4435. subTracks.append({'title':subLabel + '_' + subLang, 'url':subUrl, 'lang':subLang, 'format':'srt'})
  4436. # start https://github.com/whitecream01/WhiteCream-V0.0.1/blob/master/plugin.video.uwc/plugin.video.uwc-1.0.51.zip?raw=true
  4437. def decode(encoded):
  4438. for octc in (c for c in re.findall(r'\\(\d{2,3})', encoded)):
  4439. encoded = encoded.replace(r'\%s' % octc, chr(int(octc, 8)))
  4440. return encoded.decode('utf8')
  4441. def base10toN(num,n):
  4442. num_rep={10:'a', 11:'b',12:'c',13:'d',14:'e',15:'f',16:'g',17:'h',18:'i',19:'j',20:'k',21:'l',22:'m',23:'n',24:'o',25:'p',26:'q',27:'r',28:'s',29:'t',30:'u',31:'v',32:'w',33:'x',34:'y',35:'z'}
  4443. new_num_string=''
  4444. current=num
  4445. while current!=0:
  4446. remainder=current%n
  4447. if 36>remainder>9:
  4448. remainder_string=num_rep[remainder]
  4449. elif remainder>=36:
  4450. remainder_string='('+str(remainder)+')'
  4451. else:
  4452. remainder_string=str(remainder)
  4453. new_num_string=remainder_string+new_num_string
  4454. current=current/n
  4455. return new_num_string
  4456. def decodeOpenLoad(aastring):
  4457. # decodeOpenLoad made by mortael, please leave this line for proper credit :)
  4458. #aastring = re.search(r"<video(?:.|\s)*?<script\s[^>]*?>((?:.|\s)*?)</script", html, re.DOTALL | re.IGNORECASE).group(1)
  4459. aastring = aastring.replace("(゚Д゚)[゚ε゚]+(o゚ー゚o)+ ((c^_^o)-(c^_^o))+ (-~0)+ (゚Д゚) ['c']+ (-~-~1)+","")
  4460. aastring = aastring.replace("((゚ー゚) + (゚ー゚) + (゚Θ゚))", "9")
  4461. aastring = aastring.replace("((゚ー゚) + (゚ー゚))","8")
  4462. aastring = aastring.replace("((゚ー゚) + (o^_^o))","7")
  4463. aastring = aastring.replace("((o^_^o) +(o^_^o))","6")
  4464. aastring = aastring.replace("((゚ー゚) + (゚Θ゚))","5")
  4465. aastring = aastring.replace("(゚ー゚)","4")
  4466. aastring = aastring.replace("((o^_^o) - (゚Θ゚))","2")
  4467. aastring = aastring.replace("(o^_^o)","3")
  4468. aastring = aastring.replace("(゚Θ゚)","1")
  4469. aastring = aastring.replace("(+!+[])","1")
  4470. aastring = aastring.replace("(c^_^o)","0")
  4471. aastring = aastring.replace("(0+0)","0")
  4472. aastring = aastring.replace("(゚Д゚)[゚ε゚]","\\")
  4473. aastring = aastring.replace("(3 +3 +0)","6")
  4474. aastring = aastring.replace("(3 - 1 +0)","2")
  4475. aastring = aastring.replace("(!+[]+!+[])","2")
  4476. aastring = aastring.replace("(-~-~2)","4")
  4477. aastring = aastring.replace("(-~-~1)","3")
  4478. aastring = aastring.replace("(-~0)","1")
  4479. aastring = aastring.replace("(-~1)","2")
  4480. aastring = aastring.replace("(-~3)","4")
  4481. aastring = aastring.replace("(0-0)","0")
  4482. decodestring = re.search(r"\\\+([^(]+)", aastring, re.DOTALL | re.IGNORECASE).group(1)
  4483. decodestring = "\\+"+ decodestring
  4484. decodestring = decodestring.replace("+","")
  4485. decodestring = decodestring.replace(" ","")
  4486. decodestring = decode(decodestring)
  4487. decodestring = decodestring.replace("\\/","/")
  4488. if 'toString' in decodestring:
  4489. base = re.compile(r"toString\(a\+(\d+)", re.DOTALL | re.IGNORECASE).findall(decodestring)[0]
  4490. base = int(base)
  4491. match = re.compile(r"(\(\d[^)]+\))", re.DOTALL | re.IGNORECASE).findall(decodestring)
  4492. for repl in match:
  4493. match1 = re.compile(r"(\d+),(\d+)", re.DOTALL | re.IGNORECASE).findall(repl)
  4494. base2 = base + int(match1[0][0])
  4495. repl2 = base10toN(int(match1[0][1]),base2)
  4496. decodestring = decodestring.replace(repl,repl2)
  4497. decodestring = decodestring.replace("+","")
  4498. decodestring = decodestring.replace("\"","")
  4499. return decodestring
  4500. else:
  4501. return decodestring
  4502. return videourl
  4503. # end https://github.com/whitecream01/WhiteCream-V0.0.1/blob/master/plugin.video.uwc/plugin.video.uwc-1.0.51.zip?raw=true
  4504. videoUrl = ''
  4505. data = self.cm.ph.getAllItemsBeetwenMarkers(data, '<script type="text/javascript">゚ω゚', '</script>', withMarkers=False, caseSensitive=False)
  4506. for item in data:
  4507. try:
  4508. tmp = decodeOpenLoad(item)
  4509. printDBG(tmp)
  4510. tmp = self.cm.ph.getSearchGroups(tmp, r"(http[^\}]+)", ignoreCase=True)[0]
  4511. if tmp.startswith('http'):
  4512. videoUrl = tmp.replace('\\/', '/')
  4513. sts, response = self.cm.getPage(tmp, {'return_data':False, 'header':HTTP_HEADER})
  4514. size = int(response.headers['Content-Length'])
  4515. videoUrl = response.geturl()
  4516. response.close()
  4517. if size < 40 * 1024 * 1024:
  4518. SetIPTVPlayerLastHostError('The openload.co rejects to many connections one by one.\nWait some time and try again.')
  4519. continue
  4520. params = dict(HTTP_HEADER)
  4521. params['external_sub_tracks'] = subTracks
  4522. return urlparser.decorateUrl(videoUrl, params)
  4523. except Exception:
  4524. printExc()
  4525. return False
  4526. def parserGAMETRAILERS(self, baseUrl):
  4527. printDBG("parserGAMETRAILERS baseUrl[%r]" % baseUrl )
  4528. list = GametrailersIE()._real_extract(baseUrl)[0]['formats']
  4529. for idx in range(len(list)):
  4530. width = int(list[idx].get('width', 0))
  4531. height = int(list[idx].get('height', 0))
  4532. bitrate = int(list[idx].get('bitrate', 0))
  4533. if 0 != width or 0 != height:
  4534. name = '%sx%s' % (width, height)
  4535. elif 0 != bitrate:
  4536. name = 'bitrate %s' % (bitrate)
  4537. else:
  4538. name = '%s.' % (idx + 1)
  4539. list[idx]['name'] = name
  4540. return list
  4541. def parserVEVO(self, baseUrl):
  4542. printDBG("parserVEVO baseUrl[%r]" % baseUrl )
  4543. videoUrls = self.getVevoIE()._real_extract(baseUrl)['formats']
  4544. for idx in range(len(videoUrls)):
  4545. width = int(videoUrls[idx].get('width', 0))
  4546. height = int(videoUrls[idx].get('height', 0))
  4547. bitrate = int(videoUrls[idx].get('bitrate', 0)) / 8
  4548. name = ''
  4549. if 0 != bitrate:
  4550. name = 'bitrate %s' % (formatBytes(bitrate, 0).replace('.0', '')+'/s')
  4551. if 0 != width or 0 != height:
  4552. name += ' %sx%s' % (width, height)
  4553. if '' == name:
  4554. name = '%s.' % (idx + 1)
  4555. videoUrls[idx]['name'] = name
  4556. if 0 < len(videoUrls):
  4557. max_bitrate = int(config.plugins.iptvplayer.vevo_default_quality.value)
  4558. def __getLinkQuality( itemLink ):
  4559. return int(itemLink['bitrate'])
  4560. videoUrls = CSelOneLink(videoUrls, __getLinkQuality, max_bitrate).getSortedLinks()
  4561. if config.plugins.iptvplayer.vevo_use_default_quality.value:
  4562. videoUrls = [videoUrls[0]]
  4563. return videoUrls
  4564. def parserSHAREDSX(self, baseUrl):
  4565. printDBG("parserSHAREDSX baseUrl[%r]" % baseUrl )
  4566. # based on https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/shared.py
  4567. sts, data = self.cm.getPage(baseUrl)
  4568. if '>File does not exist<' in data:
  4569. SetIPTVPlayerLastHostError('Video %s does not exist' % baseUrl)
  4570. return False
  4571. data = self.cm.ph.getDataBeetwenMarkers(data, '<form', '</form>', False)[1]
  4572. data = re.compile('name="([^"]+?)"[^>]*?value="([^"]+?)"').findall(data)
  4573. post_data = dict(data)
  4574. sts, data = self.cm.getPage(baseUrl, {'header':self.HTTP_HEADER}, post_data)
  4575. if not sts: return False
  4576. videoUrl = self.cm.ph.getSearchGroups(data, 'data-url="([^"]+)"')[0]
  4577. if videoUrl.startswith('http'): return videoUrl
  4578. return False
  4579. def parserPOSIEDZEPL(self, baseUrl):
  4580. printDBG("parserPOSIEDZEPL baseUrl[%r]" % baseUrl)
  4581. HTTP_HEADER= { 'User-Agent':"Mozilla/5.0", 'Referer':baseUrl }
  4582. if '/e.' not in baseUrl:
  4583. video_id = self.cm.ph.getSearchGroups(baseUrl+'/', '/([A-Za-z0-9]{10})[/.?]')[0]
  4584. url = 'http://e.posiedze.pl/' + video_id
  4585. else:
  4586. url = baseUrl
  4587. sts, data = self.cm.getPage(url, {'header':HTTP_HEADER})
  4588. if not sts: return False
  4589. videoUrl = self.cm.ph.getSearchGroups(data, """["']*file["']*[ ]*?:[ ]*?["']([^"^']+?)['"]""")[0]
  4590. if videoUrl.startswith('http'): return urlparser.decorateUrl(videoUrl)
  4591. return False
  4592. def parserNEODRIVECO(self, baseUrl):
  4593. printDBG("parserNEODRIVECO baseUrl[%r]" % baseUrl)
  4594. #http://neodrive.co/embed/EG0F2UYFNR2CN1CUDNT2I5OPN/
  4595. HTTP_HEADER= { 'User-Agent':"Mozilla/5.0", 'Referer':baseUrl }
  4596. sts, data = self.cm.getPage(baseUrl, {'header':HTTP_HEADER})
  4597. if not sts: return False
  4598. videoUrl = self.cm.ph.getSearchGroups(data, """["']*vurl["']*[ ]*?=[ ]*?["']([^"^']+?)['"]""")[0]
  4599. if videoUrl.startswith('http'): return urlparser.decorateUrl(videoUrl)
  4600. return False
  4601. def parserMIPLAYERNET(self, baseUrl):
  4602. printDBG("parserMIPLAYERNET baseUrl[%r]" % baseUrl)
  4603. Referer = strwithmeta(baseUrl).meta.get('Referer', baseUrl)
  4604. HTTP_HEADER= { 'User-Agent':"Mozilla/5.0", 'Referer':Referer }
  4605. sts, data = self.cm.getPage(baseUrl, {'header':HTTP_HEADER})
  4606. if not sts: return False
  4607. url2 = self.cm.ph.getSearchGroups(data, '''<iframe[^>]*?src=["'](http://miplayer.net[^"^']+?)["']''', 1, True)[0]
  4608. if url2 != '':
  4609. sts, data = self.cm.getPage(url2, {'header':HTTP_HEADER})
  4610. if not sts: return False
  4611. curl = self.cm.ph.getSearchGroups(data, '''curl[ ]*?=[ ]*?["']([^"^']+?)["']''', 1, True)[0]
  4612. curl = base64.b64decode(curl)
  4613. if curl.split('?')[0].endswith('.m3u8'):
  4614. return getDirectM3U8Playlist(curl, checkExt=False)
  4615. elif curl.startswith('rtmp'):
  4616. swfUrl = 'http://p.jwpcdn.com/6/12/jwplayer.flash.swf'
  4617. curl += ' swfUrl=%s pageUrl=%s token=OOG17t.x#K9Vh#| ' % (swfUrl, url2)
  4618. #curl += ' token=OOG17t.x#K9Vh#| '
  4619. return curl
  4620. return False
  4621. def parserYOCASTTV(self, baseUrl):
  4622. printDBG("parserYOCASTTV baseUrl[%r]" % baseUrl)
  4623. Referer = strwithmeta(baseUrl).meta.get('Referer', baseUrl)
  4624. HTTP_HEADER= { 'User-Agent':"Mozilla/5.0", 'Referer':Referer }
  4625. sts, data = self.cm.getPage(baseUrl, {'header':HTTP_HEADER})
  4626. if not sts: return False
  4627. swfUrl = self.cm.ph.getSearchGroups(data, '''["'](http[^'^"]+?swf)['"]''')[0]
  4628. url = self.cm.ph.getSearchGroups(data, '''streamer[^'^"]*?['"](rtmp[^'^"]+?)['"]''')[0]
  4629. file = self.cm.ph.getSearchGroups(data, '''file[^'^"]*?['"]([^'^"]+?)['"]''')[0].replace('.flv', '')
  4630. if '' != file and '' != url:
  4631. url += ' playpath=%s swfVfy=%s pageUrl=%s ' % (file, swfUrl, baseUrl)
  4632. printDBG(url)
  4633. return url
  4634. return False
  4635. def parserSOSTARTORG(self, baseUrl):
  4636. printDBG("parserSOSTARTORG baseUrl[%r]" % baseUrl)
  4637. Referer = strwithmeta(baseUrl).meta.get('Referer', baseUrl)
  4638. HTTP_HEADER= { 'User-Agent':"Mozilla/5.0", 'Referer':Referer }
  4639. sts, data = self.cm.getPage(baseUrl, {'header':HTTP_HEADER})
  4640. if not sts: return False
  4641. swfUrl = 'http://sostart.org/jw/jwplayer.flash.swf'
  4642. url = ''
  4643. file = self.cm.ph.getSearchGroups(data, '''file[^'^"]*?['"]([^'^"]+?)['"]''')[0]
  4644. url += file
  4645. if '' != file and '' != url:
  4646. url += ' swfVfy=%s pageUrl=%s ' % (swfUrl, baseUrl)
  4647. printDBG(url)
  4648. return url
  4649. return False
  4650. def parserSOSTARTPW(self, baseUrl):
  4651. printDBG("parserSOSTARTPW baseUrl[%r]" % baseUrl)
  4652. baseUrl = urlparser.decorateParamsFromUrl(baseUrl)
  4653. Referer = baseUrl.meta.get('Referer', '')
  4654. HTTP_HEADER = dict(self.HTTP_HEADER)
  4655. HTTP_HEADER['Referer'] = Referer
  4656. sts, data = self.cm.getPage(baseUrl, {'header':HTTP_HEADER})
  4657. if not sts: return False
  4658. data = re.sub("<!--[\s\S]*?-->", "", data)
  4659. data = re.sub("/\*[\s\S]*?\*/", "", data)
  4660. jsonUrl = self.cm.ph.getSearchGroups(data, '''getJSON\([^"^']*?['"]([^"^']+?)['"]''')[0]
  4661. if not jsonUrl.startswith('http'): return False
  4662. if 'chunklist.m3u8' in data:
  4663. hlsStream = True
  4664. sts, data = self.cm.getPage(jsonUrl, {'header':HTTP_HEADER})
  4665. if not sts: return False
  4666. printDBG(data)
  4667. data = byteify(json.loads(data))
  4668. if hlsStream:
  4669. Referer = 'http://api.peer5.com/jwplayer6/assets/jwplayer.flash.swf'
  4670. hlsUrl = data['rtmp']+"/"+data['streamname']+"/chunklist.m3u8"
  4671. hlsUrl = urlparser.decorateUrl(hlsUrl, {'iptv_proto':'m3u8', 'iptv_livestream':True, 'User-Agent':HTTP_HEADER['User-Agent'], 'Referer':Referer})
  4672. return getDirectM3U8Playlist(hlsUrl)
  4673. return False
  4674. def parseBROADCAST(self, baseUrl):
  4675. printDBG("parseBROADCAST baseUrl[%r]" % baseUrl)
  4676. baseUrl = urlparser.decorateParamsFromUrl(baseUrl)
  4677. Referer = baseUrl.meta.get('Referer', '')
  4678. HTTP_HEADER= { 'User-Agent':"Mozilla/5.0", 'Referer':Referer }
  4679. params = {'header':HTTP_HEADER, 'use_cookie': True, 'load_cookie': True, 'save_cookie': True, 'cookiefile': GetCookieDir('broadcast.cookie')}
  4680. sts, data = self.cm.getPage(baseUrl, params)
  4681. if not sts: return False
  4682. data = re.sub("<!--[\s\S]*?-->", "", data)
  4683. data = re.sub("/\*[\s\S]*?\*/", "", data)
  4684. curl = self.cm.ph.getSearchGroups(data, '''curl[^"^']*?=[^"^']*?['"]([^"^']+?)['"]''')[0]
  4685. curl = base64.b64decode(curl)
  4686. if not curl.startswith('http'): return False
  4687. params['header']['Referer'] = baseUrl
  4688. params['header']['X-Requested-With'] = 'XMLHttpRequest'
  4689. sts, data = self.cm.getPage(self.cm.getBaseUrl(baseUrl) + 'getToken.php', params)
  4690. if not sts: return False
  4691. printDBG(data)
  4692. data = byteify(json.loads(data))
  4693. Referer = 'http://cdn.bro.adcast.site/jwplayer.flash.swf'
  4694. hlsUrl = curl + data['token']
  4695. hlsUrl = urlparser.decorateUrl(hlsUrl, {'iptv_proto':'m3u8', 'iptv_livestream':True, 'User-Agent':HTTP_HEADER['User-Agent'], 'Referer':Referer})
  4696. return getDirectM3U8Playlist(hlsUrl)
  4697. def parserGOODRTMP(self, baseUrl):
  4698. printDBG("parserGOODRTMP baseUrl[%r]" % baseUrl)
  4699. SetIPTVPlayerLastHostError('Links from "goodrtmp.com" not supported.')
  4700. return False
  4701. def parserLIFERTMP(self, baseUrl):
  4702. printDBG("parserGOODRTMP baseUrl[%r]" % baseUrl)
  4703. SetIPTVPlayerLastHostError('Links from "life-rtmp.com" not supported.')
  4704. return False
  4705. def parserTHEACTIONLIVE(self, baseUrl):
  4706. printDBG("parserTHEACTIONLIVE baseUrl[%r]" % baseUrl)
  4707. Referer = strwithmeta(baseUrl).meta.get('Referer', baseUrl)
  4708. HTTP_HEADER= { 'User-Agent':"Mozilla/5.0", 'Referer':Referer }
  4709. sts, data = self.cm.getPage(baseUrl, {'header':HTTP_HEADER})
  4710. if not sts: return False
  4711. baseUrl = strwithmeta(baseUrl, {'Referer':baseUrl})
  4712. return urlparser().getAutoDetectedStreamLink(baseUrl, data)
  4713. def parserBIGGESTPLAYER(self, baseUrl):
  4714. printDBG("parserBIGGESTPLAYER baseUrl[%r]" % baseUrl)
  4715. Referer = strwithmeta(baseUrl).meta.get('Referer', baseUrl)
  4716. HTTP_HEADER= { 'User-Agent':"Mozilla/5.0", 'Referer':Referer }
  4717. sts, data = self.cm.getPage(baseUrl, {'header':HTTP_HEADER})
  4718. if not sts: return False
  4719. data = self.cm.ph.getDataBeetwenMarkers(data, 'sources:', '}', False)[1]
  4720. url = self.cm.ph.getSearchGroups(data, '''file[^'^"]*?['"]([^'^"]+?)['"]''')[0]
  4721. return getDirectM3U8Playlist(url)
  4722. def parserLIVEONLINE247(self, baseUrl):
  4723. printDBG("parserLIVEONLINE247 baseUrl[%r]" % baseUrl)
  4724. Referer = strwithmeta(baseUrl).meta.get('Referer', baseUrl)
  4725. HTTP_HEADER= { 'User-Agent':"Mozilla/5.0", 'Referer':Referer }
  4726. sts, data = self.cm.getPage(baseUrl, {'header':HTTP_HEADER})
  4727. if not sts: return False
  4728. swfUrl = self.cm.ph.getSearchGroups(data, '''["'](http[^'^"]+?swf)['"]''')[0]
  4729. if swfUrl == '':
  4730. swfUrl = 'http://p.jwpcdn.com/6/12/jwplayer.flash.swf'
  4731. url = self.cm.ph.getSearchGroups(data, '''file[^'^"]*?['"]([^'^"]+?)['"]''')[0]
  4732. if url.startswith('rtmp'):
  4733. url += ' swfVfy=%s pageUrl=%s ' % (swfUrl, baseUrl)
  4734. printDBG(url)
  4735. return url
  4736. else:
  4737. data = self.cm.ph.getDataBeetwenMarkers(data, 'source:', '}', False)[1]
  4738. url = self.cm.ph.getSearchGroups(data, '''hls[^'^"]*?['"]([^'^"]+?)['"]''')[0]
  4739. return getDirectM3U8Playlist(url)
  4740. return False
  4741. def parserFILEPUPNET(self, baseUrl):
  4742. printDBG("parserFILEPUPNET baseUrl[%r]" % baseUrl)
  4743. sts, data = self.cm.getPage(baseUrl)
  4744. if not sts: return False
  4745. data = self.cm.ph.getDataBeetwenMarkers(data, 'window.onload', '</script>', False)[1]
  4746. qualities = self.cm.ph.getSearchGroups(data, 'qualities:[ ]*?\[([^\]]+?)\]')[0]
  4747. qualities = self.cm.ph.getAllItemsBeetwenMarkers(qualities, '"', '"', False)
  4748. defaultQuality = self.cm.ph.getSearchGroups(data, 'defaultQuality:[ ]*?"([^"]+?)"')[0]
  4749. qualities.remove(defaultQuality)
  4750. sub_tracks = []
  4751. subData = self.cm.ph.getDataBeetwenMarkers(data, 'subtitles:', ']', False)[1].split('}')
  4752. for item in subData:
  4753. if '"subtitles"' in item:
  4754. label = self.cm.ph.getSearchGroups(item, 'label:[ ]*?"([^"]+?)"')[0]
  4755. srclang = self.cm.ph.getSearchGroups(item, 'srclang:[ ]*?"([^"]+?)"')[0]
  4756. src = self.cm.ph.getSearchGroups(item, 'src:[ ]*?"([^"]+?)"')[0]
  4757. if not src.startswith('http'): continue
  4758. sub_tracks.append({'title':label, 'url':src, 'lang':srclang, 'format':'srt'})
  4759. printDBG(">>>>>>>>>>>>>>>>> sub_tracks[%s]\n[%s]" % (sub_tracks, subData))
  4760. linksTab = []
  4761. data = self.cm.ph.getDataBeetwenMarkers(data, 'sources:', ']', False)[1]
  4762. defaultUrl = self.cm.ph.getSearchGroups(data, '"(http[^"]+?)"')[0]
  4763. linksTab.append({'name':defaultQuality, 'url': strwithmeta(defaultUrl, {'Referer':'baseUrl', 'external_sub_tracks':sub_tracks})})
  4764. for item in qualities:
  4765. if '.mp4' in defaultUrl:
  4766. url = defaultUrl.replace('.mp4', '-%s.mp4' % item)
  4767. linksTab.append({'name':item, 'url': strwithmeta(url, {'Referer':'baseUrl', 'external_sub_tracks':sub_tracks})})
  4768. return linksTab
  4769. def parserHDFILMSTREAMING(self, baseUrl):
  4770. printDBG("parserHDFILMSTREAMING baseUrl[%r]" % baseUrl)
  4771. sts, data = self.cm.getPage(baseUrl)
  4772. if not sts: return False
  4773. sub_tracks = []
  4774. subData = self.cm.ph.getDataBeetwenMarkers(data, 'tracks:', ']', False)[1].split('}')
  4775. for item in subData:
  4776. if '"captions"' in item:
  4777. label = self.cm.ph.getSearchGroups(item, 'label:[ ]*?"([^"]+?)"')[0]
  4778. src = self.cm.ph.getSearchGroups(item, 'file:[ ]*?"([^"]+?)"')[0]
  4779. if not src.startswith('http'): continue
  4780. sub_tracks.append({'title':label, 'url':src, 'lang':'unk', 'format':'srt'})
  4781. linksTab = self._findLinks(data, serverName='hdfilmstreaming.com')
  4782. for idx in range(len(linksTab)):
  4783. linksTab[idx]['url'] = urlparser.decorateUrl(linksTab[idx]['url'], {'external_sub_tracks':sub_tracks})
  4784. return linksTab
  4785. def parsePUBLICVIDEOHOST(self, baseUrl):
  4786. printDBG("parsePUBLICVIDEOHOST baseUrl[%r]" % baseUrl)
  4787. sts, data = self.cm.getPage(baseUrl)
  4788. if not sts: return False
  4789. linksTab = self._findLinks(data, serverName='publicvideohost.org', m1='setup(', m2=')', contain='.mp4')
  4790. return linksTab
  4791. def parserSUPERFILMPL(self, baseUrl):
  4792. printDBG("parserSUPERFILMPL baseUrl[%r]" % baseUrl)
  4793. sts, data = self.cm.getPage(baseUrl)
  4794. if not sts: return False
  4795. data = self.cm.ph.getDataBeetwenMarkers(data, '<video ', '</video>', False)[1]
  4796. linkUrl = self.cm.ph.getSearchGroups(data, '<source[^>]+?src="(http[^"]+?)"')[0]
  4797. return linkUrl
  4798. def parserSENDVIDCOM(self, baseUrl):
  4799. printDBG("parserSENDVIDCOM baseUrl[%r]" % baseUrl)
  4800. sts, data = self.cm.getPage(baseUrl)
  4801. if not sts: return False
  4802. data = self.cm.ph.getDataBeetwenMarkers(data, '<video ', '</video>', False)[1]
  4803. linkUrl = self.cm.ph.getSearchGroups(data, '<source[^>]+?src="([^"]+?)"')[0]
  4804. if linkUrl.startswith('//'): linkUrl = 'http:' + linkUrl
  4805. return linkUrl
  4806. def parserFILEHOOT(self, baseUrl):
  4807. printDBG("parserFILEHOOT baseUrl[%r]" % baseUrl)
  4808. if 'embed-' not in baseUrl:
  4809. baseUrl = 'http://filehoot.com/embed-%s-1046x562.html' % baseUrl.split('/')[-1].replace('.html', '')
  4810. sts, data = self.cm.getPage(baseUrl)
  4811. if not sts: return False
  4812. data = re.search('file:[ ]*?"([^"]+?)"', data)
  4813. if data:
  4814. linkVideo = data.group(1)
  4815. printDBG('parserFILEHOOT direct link: ' + linkVideo)
  4816. return linkVideo
  4817. return False
  4818. def parserSSH101COM(self, baseUrl):
  4819. printDBG("parserFILEHOOT baseUrl[%r]" % baseUrl)
  4820. Referer = strwithmeta(baseUrl).meta.get('Referer', baseUrl)
  4821. HTTP_HEADER= { 'User-Agent':"Mozilla/5.0", 'Referer':Referer }
  4822. sts, data = self.cm.getPage(baseUrl, {'header':HTTP_HEADER})
  4823. if not sts: return False
  4824. data = re.search('file:[ ]*?"([^"]+?)"', data).group(1)
  4825. if data.split('?')[0].endswith('.m3u8'):
  4826. return getDirectM3U8Playlist(data)
  4827. return False
  4828. def parserTWITCHTV(self, baseUrl):
  4829. printDBG("parserFILEHOOT baseUrl[%r]" % baseUrl)
  4830. if 'channel' in baseUrl:
  4831. data = baseUrl + '&'
  4832. else:
  4833. sts, data = self.cm.getPage(baseUrl)
  4834. channel = self.cm.ph.getSearchGroups(data, '''channel=([^&^'^"]+?)[&'"]''')[0]
  4835. MAIN_URLS = 'https://api.twitch.tv/'
  4836. CHANNEL_TOKEN_URL = MAIN_URLS + 'api/channels/%s/access_token'
  4837. LIVE_URL = 'http://usher.justin.tv/api/channel/hls/%s.m3u8?token=%s&sig=%s&allow_source=true'
  4838. if '' != channel:
  4839. url = CHANNEL_TOKEN_URL % channel
  4840. sts, data = self.cm.getPage(url)
  4841. urlTab = []
  4842. if sts:
  4843. try:
  4844. data = byteify( json.loads(data) )
  4845. url = LIVE_URL % (channel, urllib.quote(data['token']), data['sig'])
  4846. data = getDirectM3U8Playlist(url, checkExt=False)
  4847. for item in data:
  4848. item['url'] = urlparser.decorateUrl(item['url'], {'iptv_proto':'m3u8', 'iptv_livestream':True})
  4849. urlTab.append(item)
  4850. except: printExc()
  4851. return urlTab
  4852. return False
  4853. def parserMOONWALKCC(self, baseUrl):
  4854. printDBG("parserMOONWALKCC baseUrl[%r]" % baseUrl)
  4855. return self.getMoonwalkParser().getDirectLinks(baseUrl)
  4856. url = baseUrl
  4857. baseUrl = 'http://' + self.cm.ph.getDataBeetwenMarkers(baseUrl, '://', '/', False)[1]
  4858. HTTP_HEADER= {'User-Agent':'Mozilla/5.0', 'Referer':url}
  4859. COOKIEFILE = self.COOKIE_PATH + "moonwalkcc.cookie"
  4860. params = {'header':HTTP_HEADER, 'use_cookie': True, 'save_cookie': True, 'load_cookie': False, 'cookiefile': COOKIEFILE}
  4861. sts, data = self.cm.getPage( url, params)
  4862. if not sts: return False
  4863. contentData = self.cm.ph.getDataBeetwenMarkers(data, 'setRequestHeader|', '|beforeSend', False)[1]
  4864. csrfToken = self.cm.ph.getSearchGroups(data, '<meta name="csrf-token" content="([^"]+?)"')[0]
  4865. cd = self.cm.ph.getSearchGroups(data, 'var condition_detected = ([^;]+?);')[0]
  4866. if 'true' == cd: cd = 1
  4867. else: cd = 0
  4868. data = self.cm.ph.getDataBeetwenMarkers(data, '/sessions/create_session', '.success', False)[1]
  4869. partner = self.cm.ph.getSearchGroups(data, 'partner: ([^,]+?),')[0]
  4870. if 'null' in partner: partner = ''
  4871. d_id = self.cm.ph.getSearchGroups(data, 'd_id: ([^,]+?),')[0]
  4872. video_token = self.cm.ph.getSearchGroups(data, "video_token: '([^,]+?)'")[0]
  4873. content_type = self.cm.ph.getSearchGroups(data, "content_type: '([^']+?)'")[0]
  4874. access_key = self.cm.ph.getSearchGroups(data, "access_key: '([^']+?)'")[0]
  4875. params['header']['Content-Data'] = base64.b64encode(contentData)
  4876. params['header']['X-CSRF-Token'] = csrfToken
  4877. params['header']['X-Requested-With'] = 'XMLHttpRequest'
  4878. params['load_cookie'] = True
  4879. post_data = {'partner':partner, 'd_id':d_id, 'video_token':video_token, 'content_type':content_type, 'access_key':access_key, 'cd':cd}
  4880. sts, data = self.cm.getPage( '%s/sessions/create_session' % baseUrl , params, post_data)
  4881. if not sts: return False
  4882. data = byteify( json.loads(data) )
  4883. printDBG(getF4MLinksWithMeta(data["manifest_f4m"]))
  4884. return getDirectM3U8Playlist(data["manifest_m3u8"])
  4885. def parserEASYVIDORG(self, baseUrl):
  4886. printDBG("parserEASYVIDORG baseUrl[%r]" % baseUrl)
  4887. def _findLinks(data):
  4888. return self._findLinks(data, 'easyvid.org')
  4889. return self._parserUNIVERSAL_A(baseUrl, 'http://easyvid.org/embed-{0}-640x360.html', _findLinks)
  4890. def parserMYSTREAMLA(self, baseUrl):
  4891. printDBG("parserMYSTREAMLA baseUrl[%r]" % baseUrl)
  4892. def _findLinks(data):
  4893. return self._findLinks(data, 'mystream.la')
  4894. return self._parserUNIVERSAL_A(baseUrl, 'http://mystream.la/external/{0}', _findLinks)
  4895. def parserOKRU(self, baseUrl):
  4896. printDBG("parserOKRU baseUrl[%r]" % baseUrl)
  4897. if 'videoPlayerMetadata' not in baseUrl:
  4898. video_id = self.cm.ph.getSearchGroups(baseUrl+'/', '/([0-9]+)/')[0]
  4899. if video_id == '': return False
  4900. url = 'http://ok.ru/dk?cmd=videoPlayerMetadata&mid=%s' % video_id
  4901. else:
  4902. url = baseUrl
  4903. HTTP_HEADER= { 'User-Agent':'Mozilla/5.0',
  4904. 'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  4905. 'Referer':baseUrl,
  4906. 'Cookie':'_flashVersion=18',
  4907. 'X-Requested-With':'XMLHttpRequest'}
  4908. sts, data = self.cm.getPage(url, {'header':HTTP_HEADER})
  4909. if not sts: return False
  4910. data = byteify(json.loads(data))
  4911. urlsTab = []
  4912. for item in data['videos']:
  4913. url = item['url'].replace('&ct=4&', '&ct=0&') + '&bytes'#=0-7078'
  4914. url = strwithmeta(url, {'Referer':baseUrl, 'User-Agent':HTTP_HEADER['User-Agent']})
  4915. urlsTab.append({'name':item['name'], 'url':url})
  4916. return urlsTab[::-1]
  4917. def parserALLOCINEFR(self, baseUrl):
  4918. printDBG("parserOKRU baseUrl[%r]" % baseUrl)
  4919. # based on https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/allocine.py
  4920. _VALID_URL = r'https?://(?:www\.)?allocine\.fr/_?(?P<typ>article|video|film|video|film)/(iblogvision.aspx\?cmedia=|fichearticle_gen_carticle=|player_gen_cmedia=|fichefilm_gen_cfilm=|video-)(?P<id>[0-9]+)(?:\.html)?'
  4921. mobj = re.match(_VALID_URL, baseUrl)
  4922. typ = mobj.group('typ')
  4923. display_id = mobj.group('id')
  4924. sts, webpage = self.cm.getPage(baseUrl)
  4925. if not sts: return False
  4926. if 'film' == type:
  4927. video_id = self.cm.ph.getSearchGroups(webpage, r'href="/video/player_gen_cmedia=([0-9]+).+"')[0]
  4928. else:
  4929. player = self.cm.ph.getSearchGroups(webpage, r'data-player=\'([^\']+)\'>')[0]
  4930. if player != '':
  4931. player_data = byteify(json.loads(player))
  4932. video_id = player_data['refMedia']
  4933. else:
  4934. model = self.cm.ph.getSearchGroups(webpage, r'data-model="([^"]+)">')[0]
  4935. model_data = byteify(json.loads(unescapeHTML(model)))
  4936. video_id = model_data['id']
  4937. sts, data = self.cm.getPage('http://www.allocine.fr/ws/AcVisiondataV5.ashx?media=%s' % video_id)
  4938. if not sts: return False
  4939. data = byteify(json.loads(data))
  4940. quality = ['hd', 'md', 'ld']
  4941. urlsTab = []
  4942. for item in quality:
  4943. url = data['video'].get(item + 'Path', '')
  4944. if not url.startswith('http'):
  4945. continue
  4946. urlsTab.append({'name':item, 'url':url})
  4947. return urlsTab
  4948. def parserLIVESTRAMTV(self, baseUrl):
  4949. printDBG("parserLIVESTRAMTV baseUrl[%r]" % baseUrl)
  4950. url = 'http://www.live-stream.tv/'
  4951. HTTP_HEADER= { 'User-Agent':'Mozilla/5.0',
  4952. 'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  4953. 'Referer':baseUrl}
  4954. COOKIEFILE = self.COOKIE_PATH + "live-stream.tv.cookie"
  4955. params = {'header':HTTP_HEADER, 'use_cookie': True, 'save_cookie': True, 'load_cookie': True, 'cookiefile': COOKIEFILE}
  4956. def updateStreamStatistics(channel, quality, statserver):
  4957. upBaseUrl = 'http://'+statserver+'.ucount.in/stats/update/custom/lstv/'+channel+'/'+quality
  4958. tm = str(int(time.time() * 1000))
  4959. upUrl = upBaseUrl + "&_="+tm+"&callback=?"
  4960. std, data = self.cm.getPage(upUrl, params)
  4961. return upBaseUrl
  4962. sts, data = self.cm.getPage(baseUrl, params)
  4963. if not sts: return
  4964. url = self.cm.ph.getSearchGroups(data, '''<iframe[^>]+?src=["'](http[^"^']+?)["']''', 1, True)[0]
  4965. sts, data = self.cm.getPage(url, params)
  4966. if not sts: return
  4967. def _getUpData(dat):
  4968. upData = self.cm.ph.getDataBeetwenMarkers(dat, 'updateStreamStatistics', ';', False)[1]
  4969. upData = re.compile('''['"]([^'^"]+?)['"]''').findall(upData)
  4970. return upData
  4971. def _getVidUrl(dat):
  4972. return self.cm.ph.getSearchGroups(dat, r'''movie=['"](http[^'^"]+?hls[^'^"]+?)['"]''')[0]
  4973. tmpData = self.cm.ph.getDataBeetwenMarkers(data, "eval(", '</script>', True)[1]
  4974. printDBG(tmpData)
  4975. upData = None
  4976. vidUrl = None
  4977. while 'eval' in tmpData and (upData == None or vidUrl == None):
  4978. tmp = tmpData.split('eval(')
  4979. if len(tmp): del tmp[0]
  4980. tmpData = ''
  4981. for item in tmp:
  4982. for decFun in [VIDEOWEED_decryptPlayerParams, SAWLIVETV_decryptPlayerParams]:
  4983. tmpData = unpackJSPlayerParams('eval('+item, decFun, 0)
  4984. if '' != tmpData: break
  4985. printDBG(tmpData)
  4986. if 'updateStreamStatistics' in tmpData:
  4987. upData = _getUpData(tmpData)
  4988. if 0 == len(upData): upData = None
  4989. if 'movie' in tmpData and 'hls' in tmpData:
  4990. vidUrl = _getVidUrl(tmpData)
  4991. if '' == vidUrl: vidUrl = None
  4992. if None == upData:
  4993. upData = _getUpData(data)
  4994. if None == vidUrl:
  4995. vidUrl = _getVidUrl(data)
  4996. #params['timeout'] = 5
  4997. #upBaseUrl = updateStreamStatistics(upData[0], upData[1], upData[2])
  4998. #pyCmd = GetPyScriptCmd('livestreamtv') + ' "%s" "%s" ' % (upBaseUrl, baseUrl)
  4999. #, 'iptv_refresh_cmd':pyCmd
  5000. marker = '.m3u8'
  5001. if marker in vidUrl:
  5002. vidUrl = strwithmeta(vidUrl, {'iptv_proto':'m3u8', 'iptv_m3u8_skip_seg':2, 'Referer':'http://static.live-stream.tv/player/player.swf', 'User-Agent':HTTP_HEADER['User-Agent']})
  5003. return getDirectM3U8Playlist(vidUrl, False)
  5004. tmpVid = vidUrl[:vidUrl.find(marker)+len(marker)]
  5005. tmpVid = strwithmeta(tmpVid, vidUrl.meta)
  5006. tab = getDirectM3U8Playlist(tmpVid, False)
  5007. if len(tab): return tab
  5008. else: return getDirectM3U8Playlist(vidUrl, False)
  5009. urlsTab = []
  5010. for item in tab:
  5011. item['url'] = strwithmeta(item['url'], {'iptv_m3u8_skip_seg':2, 'Referer':'http://static.live-stream.tv/player/player.swf', 'User-Agent':HTTP_HEADER['User-Agent']})
  5012. urlsTab.append(item)
  5013. return urlsTab
  5014. return False
  5015. def parserZEROCASTTV(self, baseUrl):
  5016. printDBG("parserZEROCASTTV baseUrl[%r]" % baseUrl)
  5017. if 'embed.php' in baseUrl:
  5018. url = baseUrl
  5019. elif 'chan.php?' in baseUrl:
  5020. sts, data = self.cm.getPage(baseUrl)
  5021. if not sts: return False
  5022. data = self.cm.ph.getDataBeetwenMarkers(data, '<body ', '</body>', False)[1]
  5023. url = self.cm.ph.getSearchGroups(data, r'''src=['"](http[^"^']+)['"]''')[0]
  5024. if 'embed.php' not in url:
  5025. sts, data = self.cm.getPage(url)
  5026. if not sts: return False
  5027. url = self.cm.ph.getSearchGroups(data, r'''var [^=]+?=[^'^"]*?['"](http[^'^"]+?)['"];''')[0]
  5028. if url == '': return False
  5029. sts, data = self.cm.getPage(url)
  5030. if not sts: return False
  5031. channelData = self.cm.ph.getSearchGroups(data, r'''unescape\(['"]([^'^"]+?)['"]\)''')[0]
  5032. channelData = urllib.unquote(channelData)
  5033. if channelData == '':
  5034. data = self.cm.ph.getSearchGroups(data, '<h1[^>]*?>([^<]+?)<')[0]
  5035. SetIPTVPlayerLastHostError(data)
  5036. if channelData.startswith('rtmp'):
  5037. channelData += ' live=1 '
  5038. return channelData
  5039. return False
  5040. def parserCLOUDYEC(self, baseUrl):
  5041. printDBG("parserCLOUDYEC baseUrl[%r]" % baseUrl)
  5042. #based on https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/cloudy.py
  5043. _VALID_URL = r'''(?x)
  5044. https?://(?:www\.)?(?P<host>cloudy\.ec|videoraj\.ch)/
  5045. (?:v/|embed\.php\?id=)
  5046. (?P<id>[A-Za-z0-9]+)
  5047. '''
  5048. _EMBED_URL = 'http://www.%s/embed.php?id=%s'
  5049. _API_URL = 'http://www.%s/api/player.api.php?%s'
  5050. _MAX_TRIES = 2
  5051. mobj = re.match(_VALID_URL, baseUrl)
  5052. video_host = mobj.group('host')
  5053. video_id = mobj.group('id')
  5054. url = _EMBED_URL % (video_host, video_id)
  5055. sts, data = self.cm.getPage(url)
  5056. if not sts: return False
  5057. file_key = self.cm.ph.getSearchGroups(data, r'key\s*:\s*"([^"]+)"')[0]
  5058. if '' == file_key:
  5059. file_key = self.cm.ph.getSearchGroups(data, r'filekey\s*=\s*"([^"]+)"')[0]
  5060. def _extract_video(video_host, video_id, file_key, error_url=None, try_num=0):
  5061. if try_num > _MAX_TRIES - 1:
  5062. return False
  5063. form = {'file': video_id, 'key': file_key}
  5064. if error_url:
  5065. form.update({'numOfErrors': try_num, 'errorCode': '404', 'errorUrl': error_url})
  5066. data_url = _API_URL % (video_host, urllib.urlencode(form))
  5067. sts, player_data = self.cm.getPage(data_url)
  5068. if not sts: return sts
  5069. data = parse_qs(player_data)
  5070. try_num += 1
  5071. if 'error' in data:
  5072. return False
  5073. title = data.get('title', [None])[0]
  5074. if title:
  5075. title = title.replace('&asdasdas', '').strip()
  5076. video_url = data.get('url', [None])[0]
  5077. if video_url:
  5078. sts, data = self.cm.getPage(video_url, {'return_data':False})
  5079. data.close()
  5080. if not sts:
  5081. return self._extract_video(video_host, video_id, file_key, video_url, try_num)
  5082. return [{'id': video_id, 'url': video_url, 'name': title}]
  5083. return _extract_video(video_host, video_id, file_key)
  5084. def parserSWIROWNIA(self, baseUrl):
  5085. printDBG("Ekstraklasa.parserSWIROWNIA baseUrl[%r]" % baseUrl)
  5086. def fun1(x):
  5087. o = ""
  5088. l = len(x)
  5089. i = l - 1;
  5090. while i >= 0:
  5091. try:
  5092. o += x[i]
  5093. except:
  5094. pass
  5095. i -= 1
  5096. return o
  5097. def fun2(x):
  5098. o = ""
  5099. ol = len(x)
  5100. l = ol
  5101. while ord(x[l/13]) != 48:
  5102. try:
  5103. x += x
  5104. l += l
  5105. except:
  5106. pass
  5107. i = l - 1
  5108. while i >= 0:
  5109. try:
  5110. o += x[i]
  5111. except:
  5112. pass
  5113. i -= 1
  5114. return o[:ol]
  5115. def fun3(x, y, a=1):
  5116. o = ""
  5117. i = 0
  5118. l = len(x)
  5119. while i<l:
  5120. if i<y:
  5121. y += a
  5122. y %= 127
  5123. o += JS_FromCharCode(ord(x[i]) ^ y)
  5124. y += 1
  5125. i += 1
  5126. return o
  5127. sts, data = self.cm.getPage(baseUrl)
  5128. if not sts: return []
  5129. data = data[data.find('x="')+2 : data.rfind('"')+1]
  5130. dataTab = data.split('+\n')
  5131. data = ""
  5132. for line in dataTab:
  5133. line = line.strip()
  5134. if '"' != line[0] or '"' != line[-1]:
  5135. raise Exception("parserSWIROWNIA parsing ERROR")
  5136. data += line[1:-1]
  5137. def backslashUnEscaped(data):
  5138. #return pythonUnescape(data)
  5139. #return codecs.decode(data, "unicode_escape").replace('\\,', ',')
  5140. #return re.sub(r'\\(.)', r'\1', data)
  5141. #try:
  5142. # return data.decode('unicode-escape')
  5143. #except:
  5144. # printExc()
  5145. #return re.sub(r'\\(.)', r'\1', data)
  5146. tmp = ''
  5147. idx = 0
  5148. while idx < len(data):
  5149. if data[idx] == '\\':
  5150. tmp += data[idx+1]
  5151. idx += 2
  5152. else:
  5153. tmp += data[idx]
  5154. idx += 1
  5155. return tmp
  5156. def printDBG2(data):
  5157. printDBG("================================================================")
  5158. printDBG( data )
  5159. printDBG("================================================================")
  5160. data = backslashUnEscaped(data)
  5161. data = data[data.find('f("')+3:data.rfind('"')]
  5162. data = fun1( data )
  5163. printDBG2(data)
  5164. data = backslashUnEscaped(data)
  5165. printDBG2(data)
  5166. data = data[data.find('f("')+3:data.rfind('"')]
  5167. printDBG2(data)
  5168. data = data.decode('string_escape')
  5169. data = fun3( data, 50, 0)
  5170. data = backslashUnEscaped(data)
  5171. printDBG2(data)
  5172. return
  5173. data = data[data.find('f("')+3:data.rfind('"')]
  5174. data = fun2( data )
  5175. data = data.decode('string-escape')
  5176. data = data[data.find('f("')+3:data.rfind('"')]
  5177. data = fun3( data, 23, 1)
  5178. data = backslashUnEscaped(data)
  5179. printDBG(data)
  5180. printDBG("------------------------------------------------------------------------------------")
  5181. return
  5182. #data = data.decode('string_escape')
  5183. #printDBG(data)
  5184. data = fun3( data, 23, 1)
  5185. #data = data.decode('string_escape')
  5186. data = backslashUnEscaped(data)
  5187. printDBG("------------------------------------------------------------------------------------")
  5188. printDBG(data)
  5189. printDBG("------------------------------------------------------------------------------------")
  5190. def parseMETAUA(self, baseUrl):
  5191. printDBG("parseMETAUA baseUrl[%s]" % baseUrl)
  5192. HTTP_HEADER= { 'User-Agent':'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10', #'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:21.0) Gecko/20100101 Firefox/21.0',
  5193. 'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' }
  5194. sts, data = self.cm.getPage(baseUrl, {'header' : HTTP_HEADER})
  5195. if not sts: return False
  5196. file_url = self.cm.ph.getSearchGroups(data, '''st_html5=['"]([^'^"]+?)['"]''')[0]
  5197. def getUtf8Str(st):
  5198. idx = 0
  5199. st2 = ''
  5200. while idx < len(st):
  5201. st2 += '\\u0' + st[idx:idx + 3]
  5202. idx += 3
  5203. return st2.decode('unicode-escape').encode('UTF-8')
  5204. if file_url.startswith('#') and 3 < len(file_url):
  5205. file_url = getUtf8Str(file_url[1:])
  5206. file_url = byteify(json.loads(file_url))['file']
  5207. if file_url.startswith('http'):
  5208. return urlparser.decorateUrl(file_url, {'iptv_livestream':False, 'User-Agent':HTTP_HEADER['User-Agent']})
  5209. return False
  5210. def parseNETUTV2(self, url):
  5211. def OIO(data, _0x84de):
  5212. _0lllOI = _0x84de[0];
  5213. enc = _0x84de[1];
  5214. i = 0;
  5215. while i < len(data):
  5216. h1 = _0lllOI.find(data[i]);
  5217. h2 = _0lllOI.find(data[i+1]);
  5218. h3 = _0lllOI.find(data[i+2]);
  5219. h4 = _0lllOI.find(data[i+3]);
  5220. i += 4;
  5221. bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;
  5222. o1 = bits >> 16 & 0xff;
  5223. o2 = bits >> 8 & 0xff;
  5224. o3 = bits & 0xff;
  5225. if h3 == 64:
  5226. enc += chr(o1);
  5227. else:
  5228. if h4 == 64:
  5229. enc += chr(o1) + chr(o2);
  5230. else:
  5231. enc += chr(o1) + chr(o2) + chr(o3);
  5232. return enc
  5233. def _0ll(string, _0x84de):
  5234. ret = _0x84de[1]
  5235. i = len(string) - 1
  5236. while i >= 0:
  5237. ret += string[i]
  5238. i -= 1
  5239. return ret
  5240. def K12K(a, typ='b'):
  5241. tmp = "G.L.M.N.Z.o.I.t.V.y.x.p.R.m.z.u.D.7.W.v.Q.n.e.0.b.=//2.6.i.k.8.X.J.B.a.s.d.H.w.f.T.3.l.c.5.Y.g.1.4.9.U.A"
  5242. tmp = tmp.split("//")
  5243. codec_a = tmp[0].split('.')
  5244. codec_b = tmp[1].split('.')
  5245. if 'd' == typ:
  5246. tmp = codec_a
  5247. codec_a = codec_b
  5248. codec_b = tmp
  5249. idx = 0
  5250. while idx < len(codec_a):
  5251. a = a.replace(codec_a[idx], "___");
  5252. a = a.replace(codec_b[idx], codec_a[idx]);
  5253. a = a.replace("___", codec_b[idx]);
  5254. idx += 1
  5255. return a
  5256. def _xc13(_arg1):
  5257. _lg27 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
  5258. _local2 = ""
  5259. _local3 = [0, 0, 0, 0]
  5260. _local4 = [0, 0, 0]
  5261. _local5 = 0
  5262. while _local5 < len(_arg1):
  5263. _local6 = 0;
  5264. while _local6 < 4 and (_local5 + _local6) < len(_arg1):
  5265. _local3[_local6] = ( _lg27.find( _arg1[_local5 + _local6] ) )
  5266. _local6 += 1
  5267. _local4[0] = ((_local3[0] << 2) + ((_local3[1] & 48) >> 4))
  5268. _local4[1] = (((_local3[1] & 15) << 4) + ((_local3[2] & 60) >> 2))
  5269. _local4[2] = (((_local3[2] & 3) << 6) + _local3[3])
  5270. _local7 = 0
  5271. while _local7 < len(_local4):
  5272. if _local3[_local7 + 1] == 64:
  5273. break
  5274. _local2 += chr(_local4[_local7])
  5275. _local7 += 1
  5276. _local5 += 4
  5277. return _local2
  5278. printDBG("parseNETUTV url[%s]\n" % url)
  5279. #http://netu.tv/watch_video.php?v=ODM4R872W3S9
  5280. match = re.search("=([0-9A-Z]+?)[^0-9^A-Z]", url + '|' )
  5281. playerUrl = "http://netu.tv/player/embed_player.php?vid=%s&autoplay=no" % match.group(1)
  5282. HTTP_HEADER= { 'User-Agent':'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:21.0) Gecko/20100101 Firefox/21.0',
  5283. 'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' }
  5284. #HTTP_HEADER['Referer'] = url
  5285. sts, data = self.cm.getPage(playerUrl, {'header' : HTTP_HEADER})
  5286. data = base64.b64decode(re.search('base64\,([^"]+?)"', data).group(1))
  5287. #printDBG(data)
  5288. l01 = re.search("='([^']+?)'", data).group(1)
  5289. _0x84de = re.search("var _0x84de=\[([^]]+?)\]", data).group(1)
  5290. _0x84de = re.compile('"([^"]*?)"').findall(_0x84de)
  5291. data = OIO( _0ll(l01, _0x84de), _0x84de )
  5292. data = re.search("='([^']+?)'", data).group(1).replace('%', '\\').decode('unicode-escape').encode('UTF-8')
  5293. data = re.compile('<input name="([^"]+?)" [^>]+? value="([^"]+?)">').findall(data)
  5294. post_data = {}
  5295. for idx in range(len(data)):
  5296. post_data[ data[idx][0] ] = data[idx][1]
  5297. sts, data = self.cm.getPage(playerUrl, {'header' : HTTP_HEADER}, post_data)
  5298. #CParsingHelper.writeToFile('/home/sulge/test.html', data)
  5299. file_vars = re.search("file='\+([^']+?)\+'", data).group(1)
  5300. file_vars = file_vars.split('+')
  5301. file_url = ''
  5302. for file_var in file_vars:
  5303. file_url += re.search('var %s = "([^"]*?)"' % file_var, data).group(1)
  5304. file_url = _xc13(K12K(file_url, 'd'))
  5305. if "http" in file_url:
  5306. return file_url
  5307. return False
  5308. def parseNETUTV(self, url):
  5309. printDBG("parseNETUTV url[%s]" % url)
  5310. # example video: http://netu.tv/watch_video.php?v=WO4OAYA4K758
  5311. printDBG("parseNETUTV url[%s]\n" % url)
  5312. #http://netu.tv/watch_video.php?v=ODM4R872W3S9
  5313. match = re.search("=([0-9a-zA-Z]+?)[^0-9^a-z^A-Z]", url + '|' )
  5314. vid = match.group(1)
  5315. HTTP_HEADER= { 'User-Agent':'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10', #'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:21.0) Gecko/20100101 Firefox/21.0',
  5316. 'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' }
  5317. #HTTP_HEADER = { 'User-Agent':'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/37.0.2062.120 Chrome/37.0.2062.120 Safari/537.36',
  5318. # 'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' }
  5319. #http://hqq.tv/player/hash.php?hash=229221213221211228239245206208212229194271217271255
  5320. if 'hash.php?hash' in url:
  5321. sts, data = self.cm.getPage(url, {'header' : HTTP_HEADER})
  5322. if not sts: return False
  5323. data = re.sub('document\.write\(unescape\("([^"]+?)"\)', lambda m: urllib.unquote(m.group(1)), data)
  5324. vid = re.search('''var[ ]+%s[ ]*=[ ]*["']([^"]*?)["']''' % 'vid', data).group(1)
  5325. playerUrl = "http://hqq.tv/player/embed_player.php?vid=%s&autoplay=no" % vid
  5326. referer = strwithmeta(url).meta.get('Referer', playerUrl)
  5327. #HTTP_HEADER['Referer'] = url
  5328. sts, data = self.cm.getPage(playerUrl, {'header' : HTTP_HEADER})
  5329. data = base64.b64decode(re.search('base64\,([^"]+?)"', data).group(1))
  5330. #printDBG(data)
  5331. l01 = re.search("='([^']+?)'", data).group(1)
  5332. _0x84de = re.search("var _0x84de=\[([^]]+?)\]", data).group(1)
  5333. _0x84de = re.compile('"([^"]*?)"').findall(_0x84de)
  5334. data = MYOBFUSCATECOM_OIO( MYOBFUSCATECOM_0ll(l01, _0x84de[1]), _0x84de[0], _0x84de[1])
  5335. data = re.search("='([^']+?)'", data).group(1).replace('%', '\\').decode('unicode-escape').encode('UTF-8')
  5336. data = re.compile('<input name="([^"]+?)" [^>]+? value="([^"]+?)">').findall(data)
  5337. post_data = {}
  5338. for idx in range(len(data)):
  5339. post_data[ data[idx][0] ] = data[idx][1]
  5340. secPlayerUrl = "http://hqq.tv/sec/player/embed_player.php?vid=%s&at=%s&autoplayed=%s&referer=on&http_referer=%s&pass=" % (vid, post_data.get('at', ''), post_data.get('autoplayed', ''), urllib.quote(referer))
  5341. HTTP_HEADER['Referer'] = referer
  5342. sts, data = self.cm.getPage(secPlayerUrl, {'header' : HTTP_HEADER}, post_data)
  5343. data = re.sub('document\.write\(unescape\("([^"]+?)"\)', lambda m: urllib.unquote(m.group(1)), data)
  5344. #CParsingHelper.writeToFile('/mnt/new2/test.html', data)
  5345. def getUtf8Str(st):
  5346. idx = 0
  5347. st2 = ''
  5348. while idx < len(st):
  5349. st2 += '\\u0' + st[idx:idx + 3]
  5350. idx += 3
  5351. return st2.decode('unicode-escape').encode('UTF-8')
  5352. file_vars = CParsingHelper.getDataBeetwenMarkers(data, 'Uppod(', ')', False)[1]
  5353. file_vars = CParsingHelper.getDataBeetwenMarkers(data, 'file:', ',', False)[1].strip()
  5354. file_vars = file_vars.split('+')
  5355. file_url = ''
  5356. for file_var in file_vars:
  5357. file_var = file_var.strip()
  5358. if 0 < len(file_var):
  5359. match = re.search('''["']([^"]*?)["']''', file_var)
  5360. if match: file_url += match.group(1)
  5361. else: file_url += re.search('''var[ ]+%s[ ]*=[ ]*["']([^"]*?)["']''' % file_var, data).group(1)
  5362. if file_url == '':
  5363. playerData = self.cm.ph.getDataBeetwenMarkers(data, 'get_md5.php', '})')[1]
  5364. playerData = self.cm.ph.getDataBeetwenMarkers(playerData, '{', '}', False)[1]
  5365. playerData = playerData.split(',')
  5366. getParams = {}
  5367. for p in playerData:
  5368. tmp = p.split(':')
  5369. printDBG(tmp)
  5370. key = tmp[0].replace('"', '').strip()
  5371. val = tmp[1].strip()
  5372. if '"' not in val:
  5373. v = re.search('''var[ ]+%s[ ]*=[ ]*["']([^"]*?)["']''' % val, data).group(1)
  5374. if '' != val: val = v
  5375. getParams[key] = val
  5376. playerUrl = 'http://hqq.tv/player/get_md5.php?' + urllib.urlencode(getParams)
  5377. sts, data = self.cm.getPage(playerUrl)
  5378. if not sts: return False
  5379. data = byteify( json.loads(data) )
  5380. file_url = data['html5_file']
  5381. printDBG(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
  5382. printDBG(data['file'])
  5383. if file_url.startswith('#') and 3 < len(file_url): file_url = getUtf8Str(file_url[1:])
  5384. #printDBG("[[[[[[[[[[[[[[[[[[[[[[%r]" % file_url)
  5385. if file_url.startswith('http'): return urlparser.decorateUrl(file_url, {'iptv_livestream':False, 'User-Agent':HTTP_HEADER['User-Agent']})
  5386. #'Range':'bytes=0-'
  5387. return False
  5388. '''
  5389. ###############################################
  5390. # start - other methods from netu.tv player.swf
  5391. ###############################################
  5392. def encodeByteArray(tab):
  5393. ret = ""
  5394. _lg27 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
  5395. idx = 0;
  5396. _local4 = [64,64,64,64]
  5397. while idx < len(tab):
  5398. tmpTab = []
  5399. while len(tmpTab) < 4 and idx < len(tab):
  5400. tmpTab.append(ord(tab[idx]))
  5401. idx += 1
  5402. _local4[0] = ((tmpTab[0] & 252) >> 2);
  5403. _local4[1] = (((tmpTab[0] & 3) << 4) | (tmpTab[1] >> 4));
  5404. _local4[2] = (((tmpTab[1] & 15) << 2) | (tmpTab[2] >> 6));
  5405. _local4[3] = (tmpTab[2] & 63);
  5406. for item in _local4:
  5407. ret += _lg27[item]
  5408. return ret
  5409. def tr(_arg1, _arg2=114, _arg3=65):
  5410. if ord(_arg1[len(_arg1) - 2]) == _arg2 and ord(_arg1[2]) == _arg3:
  5411. _local5 = "";
  5412. _local4 = len(_arg1) - 1;
  5413. while _local4 >= 0:
  5414. _local5 = _local5 + _arg1[_local4];
  5415. _local4-= 1;
  5416. _arg1 = _local5;
  5417. _local6 = _arg1[-2:];
  5418. _arg1 = _arg1[2:];
  5419. _arg1 = _arg1[0, -3];
  5420. _local6 = (_local6 / 2);
  5421. if _local6 < len(_arg1):
  5422. _local4 = _local6;
  5423. while _local4 < _arg1.length:
  5424. _arg1 = _arg1[0:_local4] + _arg1[_local4 + 1:];
  5425. _local4 = _local4 + _local6;
  5426. _arg1 = _arg1 + "!";
  5427. return _arg1
  5428. ###############################################
  5429. # end - other methods from netu.tv player.swf
  5430. ###############################################
  5431. '''
  5432. '''
  5433. def parserNEXTVIDEO(self,url):
  5434. sts, data = self.getPage(url)
  5435. if False == sts:
  5436. return False
  5437. match = re.search('file:[^"]+?"([^"]+?)"', data)
  5438. if match:
  5439. return match.group(1)
  5440. else:
  5441. return False
  5442. '''
  5443. '''
  5444. def parserDIVXSTAGE(self, url):
  5445. sts, data = self.getPage(url)
  5446. if False == sts:
  5447. return False
  5448. match = re.search('flashvars.file="([^"]+?)";', data)
  5449. if match:
  5450. file = match.group(1)
  5451. else:
  5452. return False
  5453. match = re.search('flashvars.filekey="([^"]+?)";', data)
  5454. if match:
  5455. filekey = match.group(1).replace('.', '%2E')
  5456. else:
  5457. return False
  5458. match = re.search('flashvars.cid="([^"]+?)";', data)
  5459. if match:
  5460. cid = match.group(1)
  5461. else:
  5462. return False
  5463. urlApi = 'http://www.divxstage.eu/api/player.api.php?user=undefined&cid3=undefined&file=%s&cid=%s&key=%s&numOfErrors=0&pass=undefined&cid2=undefined' %s (file, cid, filekey)
  5464. sts, data = self.getPage(url)
  5465. if False == sts:
  5466. return False
  5467. match = re.search('url=([^&]+?)&', data)
  5468. if match:
  5469. return match.group(1)
  5470. else:
  5471. return False
  5472. <input type="hidden" name="op" value="download1">
  5473. <input type="hidden" name="usr_login" value="">
  5474. <input type="hidden" name="id" value="7wtoiieyqsmv">
  5475. <input type="hidden" name="fname" value="The.Secret.Life.of.Walter.Mitty.2013.PLSUBBED.DVDscr.XViD.AC3-OzW.avi">
  5476. <input type="hidden" name="referer" value="http://vidto.me/embed-7wtoiieyqsmv-647x500.html">
  5477. <input type="hidden" name="hash" value="4upjo7kqazfuwg4ex75zwmruewqrrxbq">
  5478. {
  5479. "auto_hd": false,
  5480. "autoplay_reason": "unknown",
  5481. "default_hd": false,
  5482. "disable_native_controls": false,
  5483. "inline_player": false,
  5484. "pixel_ratio": 1,
  5485. "preload": false,
  5486. "start_muted": false,
  5487. "video_data": [{
  5488. "hd_src": "https:\\/\\/fbcdn-video-a-a.akamaihd.net\\/hvideo-ak-xpa1\\/v\\/t43.1792-2\\/1346786_597358996980898_38093_n.mp4?rl=1924&vabr=1283&oh=39547a46c1706d6985a63f451d9804ee&oe=54FB5F56&__gda__=1425759704_938e66c3e93914a0af0978780c5a3a81",
  5489. "is_hds": false,
  5490. "is_hls": false,
  5491. "rotation": 0,
  5492. "sd_src": "https:\\/\\/fbcdn-video-p-a.akamaihd.net\\/hvideo-ak-xpa1\\/v\\/t42.1790-2\\/1188227_592870284096436_64686_n.mp4?rl=563&vabr=313&oh=e891677083036d0b291ed601f85953d8&oe=54FB5B46&__gda__=1425762824_3c005c8845ab035ba6aceae1cc5f63d5",
  5493. "video_id": "201191406597661",
  5494. "sd_tag": "legacy_sd",
  5495. "hd_tag": "legacy_hd",
  5496. "sd_src_no_ratelimit": "https:\\/\\/fbcdn-video-p-a.akamaihd.net\\/hvideo-ak-xpa1\\/v\\/t42.1790-2\\/1188227_592870284096436_64686_n.mp4?oh=e891677083036d0b291ed601f85953d8&oe=54FB5B46&__gda__=1425762824_fe9007c59a8243300d34f90a3f025c71",
  5497. "hd_src_no_ratelimit": "https:\\/\\/fbcdn-video-a-a.akamaihd.net\\/hvideo-ak-xpa1\\/v\\/t43.1792-2\\/1346786_597358996980898_38093_n.mp4?oh=39547a46c1706d6985a63f451d9804ee&oe=54FB5F56&__gda__=1425759704_4d32e5007b137533f795db5c816d6ef2",
  5498. "subtitles_src": null
  5499. }],
  5500. "show_captions_default": false,
  5501. "persistent_volume": true,
  5502. "buffer_length": 0.1
  5503. }
  5504. '''