import org.serviio.library.metadata.* import org.serviio.library.online.* import org.serviio.util.* import java.io.FileInputStream import java.util.zip.GZIPInputStream import java.lang.Thread.* /* * WebResource extractor plugin for stopstream.com * based on hahasport.groovy * * see full schedule at www.stopstream.com * * @author jhb50 * Version 17 - Jan 6,2013 hahasports V17 equivalent * Version 18 - Jan 11,2013 hahasports V18 equivalent * Version 19 - Jan 11,2013 Correct refresh time error * Version 20 - Jan 12,2013 Tuned, Coolsport source change * Version 21 - Jan 13,2013 Liveall source change * Version 22 - Feb 3,2013 Many source changes, Genurls added by default to minimize extracts * Version 23 - Feb 4,2013 Site changed to www.stopstream.com * Version 24 - Feb 4,2013 Improved Expiry time logic * Version 25 - Feb 5,2013 Support Quick Refresh for subsets. * Version 26 - Feb 10,2013 Skip bad source Urls * Version 27 - Feb 18,2013 Update sources * Version 28 - Feb 19,2013 Add Livego source support * Version 29 - Mar 8,2013 Increase Extract Timeout to 60 seconds * Version 30 - Apr 15,2013 update hdcast, ilive & leton uri * Version 31 - May 23,2013 add sawlive sources, adjust event end refreshes, new web page, update ips, add featve redirect & token. * * */ class Stopstream extends WebResourceUrlExtractor { String Token = "#fe%#w@3fe%#w@3s#Ch%3al#w#fe%#w@3fe%#w@3s#Ch%3al#w@2s#Ch%3alfe%#w@3s#Ch%3al#w@2#w@2#fe%#w@3fe%#w@3s#Ch%3al#w@2s#Ch%3alfe%#w@3s#Ch%3al#w@2#w@2#fe%#w@3fe%#w@3s#Ch%3al#w@2s#Ch%3alfe%#w@3s#Ch%3al#w@2#w@2#fe%#w@3fe%#w@3s#Ch%3al#w@2s#Ch%3alfe%#w@3s#Ch%3al#w@2#w@2#fe%#w@3fe%#w@3s#Ch%3al#w@2s#Ch%3alfe%#w@3s#Ch%3al#w@2#w@2#fe%#w@3fe%#w@3s#Ch%3al#w@2s#Ch%3alfe%#w@3s#Ch%3al#w@2#w@2sad3@2s#Ch%3alfe%#w@3s#Ch%3al#w@2#w@2" long StartETime = 0 long LastETime2 = 0 long LastETime3 = 0 String ucasterUri String mipsUri String liveflashUri long lowestRefresha = 99999999 List newitems = [] List olditems = [] final VALID_FEED_URL = '^(?:https?://)?(?:www\\.)?stopstream\\.(com|tv).*?' String getExtractorName() { return 'Stopstream' } boolean extractorMatches(URL feedUrl) { return feedUrl ==~ VALID_FEED_URL } int getVersion() { return 31 } int getExtractItemsTimeout() { return 90 } Long ETimer(String msg){ long CurrentTime = System.currentTimeMillis() long Elapsed = CurrentTime - StartETime if (msg != null){ log("$msg = $Elapsed msec") } return Elapsed } Long ETimer2(String msg){ long CurrentTime = System.currentTimeMillis() long Elapsed = CurrentTime - LastETime2 LastETime2 = CurrentTime if (msg != null){ log("$msg = $Elapsed msec") } return Elapsed } Long ETimer3(String msg){ long CurrentTime = System.currentTimeMillis() long Elapsed = CurrentTime - LastETime3 LastETime3 = CurrentTime if (msg != null){ log("$msg = $Elapsed msec") } return Elapsed } Boolean URLExists(String srcURL){ URL fileURL = new URL(srcURL); if(((HttpURLConnection) fileURL.openConnection()).getResponseCode() == 404){ return false } return true } String OpenProtURL( String srcURL, String Referrer ) { def rv = "" URL url = new URL(srcURL); URLConnection conn = url.openConnection(); conn.setRequestProperty("Referer", Referrer); conn.setRequestProperty("User-Agent","Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.83 Safari/537.1"); conn.setRequestProperty("Accept-Language","en-US"); conn.setDoOutput(true); BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line; while ((line = rd.readLine()) != null) { rv += line } rd.close(); return rv } WebResourceContainer extractItems(URL resourceUrl, int maxItems) { log("Parsing with Stopstream V${getVersion()}") resourceUrl = new URL(resourceUrl.toString().replaceFirst("tv","com")) StartETime = System.currentTimeMillis() ETimer2() ucasterUri = "" mipsUri = "" liveflashUri = "" def genurls = 1 def curDate = new Date(System.currentTimeMillis()+300000) olditems = [] if (newitems){ def newitemssize = newitems.size() def nli = newitems.iterator() while (nli.hasNext()){ def newEntry = nli.next() if(newEntry.getAdditionalInfo()['XexpiresImmediately']!= true) continue def SavedExpiryDate = newEntry.getAdditionalInfo()['XexpiresOn'] if(SavedExpiryDate > new Date(0) && curDate >= SavedExpiryDate) continue olditems << newEntry } def olditemssize = olditems.size() log ( olditemssize + " items saved, " + (newitemssize - olditemssize) + " expired" ) olditems = olditems.drop(olditemssize-300) newitems = olditems } while(1) { def test_text = openURL(new URL("http://www.dogpile.com"), "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.83 Safari/537.1") def testMatch = test_text ==~ '(?s).*?Dogpile Web Search.*?' if (testMatch) break } List items = [] def itemsAdded = 0 String videoTitle = "" String rtmpUrl = "" String secCode = "" String thumbnailUrl = "" String pageThumb = "" String nextTitle = "" String itemFlag = "None" String linkTitle = "" String feed = "" String srcUrl = "" String videoUrl = "" String refreshtxt = "" def onDemand = false def repId = "" def icon = false def breaker = false String lastTitle = "" String videoTitle1 = "" String videoTitle2 = "" String videoTitle3 = "" long time = 0 long defRefreshi = 0 def lowestRefreshat = "" long itemRefresha = 0 def itemRefreshat = "" def parmMatcher = resourceUrl =~ '^(?:https?://)?(?:www\\.)?stopstream\\.com.*?genurls=([0-1])' def parmMatch = resourceUrl ==~ '^(?:https?://)?(?:www\\.)?stopstream\\.com.*?genurls=[0-1].*?' if (parmMatch){ genurls = parmMatcher[0][1].trim() } parmMatcher = resourceUrl =~ '^(?:https?://)?(?:www\\.)?stopstream\\.com.*?refresh=(.[0-9]+).*?' parmMatch = resourceUrl ==~ '^(?:https?://)?(?:www\\.)?stopstream\\.com.*?refresh=[0-9]+.*?' if (parmMatch){ defRefreshi = parmMatcher[0][1].trim().toLong() long curTime=System.currentTimeMillis()/60000 lowestRefresha = (System.currentTimeMillis()/60000) + defRefreshi + 5 } parmMatcher = resourceUrl =~ '^(?:https?://)?(?:www\\.)?stopstream\\.com.*?time=([0-9]+)' parmMatch = resourceUrl ==~ '^(?:https?://)?(?:www\\.)?stopstream\\.com.*?time=[0-9]+.*?' if (parmMatch){ time = parmMatcher[0][1].trim().toShort() if (time < -24 || time > 24) time = 0 time = time * 60 } parmMatcher = resourceUrl =~ '^(?:https?://)?(?:www\\.)?stopstream\\.com.*?repid=(.[0-9]+).*?' parmMatch = resourceUrl ==~ '^(?:https?://)?(?:www\\.)?stopstream\\.com.*?repid=[0-9]+.*?' if (parmMatch){ repId = parmMatcher[0][1].trim() icon = true onDemand = true } long curTimea = System.currentTimeMillis()/60000 if (lowestRefresha == 99999999) lowestRefreshat = "Console Default" else lowestRefreshat = new Date((lowestRefresha-5)*60000).format("H:mm 'on' E M/dd/yyyy").trim() int estreams = 1 int estreamsCount = 0 def estreamsMatcher = resourceUrl =~ '^(?:https?://)?(?:www\\.)?stopstream\\.com.*?streams=([0-9]+)' def estreamsMatch = resourceUrl ==~ '^(?:https?://)?(?:www\\.)?stopstream\\.com.*?streams=[0-9]+.*?' if (estreamsMatch){ estreams = estreamsMatcher[0][1].trim().toInteger() } if (resourceUrl.toString().contains("?")){ def maskMatcher = resourceUrl =~ '^(.*?)\\?.*?' resourceUrl = new URL(maskMatcher[0][1].trim()) } String html = resourceUrl.getText() def titleMatcher = html =~ '(?s)

(.+?)<' String pageTitle = titleMatcher[0][1].trim() if (icon){ linkTitle = "http://refreshitem" srcUrl = "http://refreshitem" videoUrl = "http://refreshitem" thumbnailUrl = "https://sites.google.com/site/serviiorss/refresh.jpg" videoTitle = "Click to Refresh " log ("ADDED 'REFRESH ON DEMAND' ") WebResourceItem item = new WebResourceItem(title: videoTitle, additionalInfo: ['resourceUrl':resourceUrl,'repId':repId,'onDemand':onDemand,'linkTitle':linkTitle,'srcUrl':srcUrl,'videoUrl':videoUrl,'thumbnailUrl':thumbnailUrl,'curTimea':curTimea,'itemRefresha':lowestRefresha]) items << item } if (html.count('
(.*?)
' for( int i = 0; i < blockMatcher.size() && breaker == false && (maxItems == -1 || itemsAdded < maxItems); i++ ) { if (ETimer() > 86000){ log ("Time Limit of 90 Seconds Reached") println "\r\nTime Limit of 90 Seconds Reached\r\n" break } def videoMatch = blockMatcher[i][2] ==~ '(?s).*?"video".*? rtmpUrl = "rtmp://37.220.34.59:1935/liverepeater/_definst_/" + idMatcher[0][1] + " live=1" } else{ log("No playpath or src= found in " + srcUrl) return } } } else if (srcUrl.contains("http://hqfooty.tv/") || srcUrl.contains("http://frametv2.blogspot.co.uk") || srcUrl.contains("http://frametv3.blogspot.co.uk")){ log("Source Link 1: $srcUrl") if (srcUrl.contains("http://frametv") || srcUrl.contains("http://hqfooty.tv/s/")){ linkTitle = openURL( new URL(srcUrl), "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.83 Safari/537.1") def srcMatcher = linkTitle =~ '(?s).*?chname="(.*?)"' def secMatch = linkTitle =~ '(?s).*?javascript">.*?chname=".*?".*?' if(!secMatch) secMatcher = linkTitle =~ '(?s)chname=(.*?)[&"]' if (!secMatcher){ log("No chname= playpath in " + srcUrl) println "No chname= playpath in " + srcUrl return } secCode = secMatcher[0][1].trim() srcUrl = "http://castasap.com/embedhd.php?chname=" + secCode log("Source Link: $srcUrl") String linkHtml = new URL(srcUrl).getText() def linkMatcher = linkHtml =~ /(?s)flashvars.*?file:.*?'(.*?)'.*?streamer:.*?'(.*?)'.*?/ if (!linkMatcher){ log("No rtmp data in " + srcUrl) println "No rtmp data in " + srcUrl return } rtmpUrl = "rtmp://" + linkMatcher[0][2] + " playpath=" + linkMatcher[0][1] + " pageurl=http://castasap.com swfVfy=0 live=1" } else if (srcUrl.contains("http://www.hdcast.tv")) { log("Source Link: $srcUrl") def secMatcher = linkTitle =~ '(?s).*?" if (liveMatcher.count > 0) { srcUrl = "http://www.ucaster.eu/embedded/" + liveMatcher [0][1] + "/" + liveMatcher [0][2] + "/620/490" log("Source Link 4: $srcUrl") if (!URLExists(srcUrl)) { log (srcUrl + " is DEADLINK") println srcUrl + " is DEADLINK" return null } println "open link " + srcUrl def srcUrl_text = OpenProtURL(srcUrl,"http://www.cricfree.tv") liveMatcher = srcUrl_text =~ "FlashVars.*?id=(.*?)&s=(.*?)&.*?" if(!liveMatcher){ println "No Playpath in " + srcUrl log("No Playpath in " + srcUrl) return } secCode = liveMatcher [0][2] + "?id=" + liveMatcher [0][1] //* now get uri if required (loadbalancer only works once) if(!ucasterUri){ def linkUri = openURL( new URL("http://www.ucaster.eu:1935/loadbalancer"), "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.83 Safari/537.1") println linkUri def UriMatcher = linkUri =~ 'redirect=(.*?)$' if(!UriMatcher) ucasterUri = "174.36.251.140" else ucasterUri = UriMatcher[0][1] } rtmpUrl = "rtmp://" + ucasterUri + "/live playpath=" + secCode + " pageUrl=http://www.ucaster.eu swfurl=http://www.ucaster.eu/static/scripts/eplayer.swf live=1" } } else if(srcUrl.contains("http://jimey.tv")){ def liveMatcher = linkTitle =~ "" def return_val = '-NOTFOUND-' if (liveMatcher.count > 0) { def referrer = srcUrl srcUrl= "http://jimey.tv/player/embedplayer.php?channel=" + liveMatcher [0][1] + "&user=" + liveMatcher[0][2] +"&width=620&height=490" log("Source Link 3: $srcUrl") if (!URLExists(srcUrl)) { log (srcUrl + " is DEADLINK") println srcUrl + " is DEADLINK" return null } println "open link " + srcUrl def srcUrl_text = OpenProtURL(srcUrl,referrer) def errorMatch = srcUrl_text ==~ '(?s).*?channel has been deleted.*?' if (errorMatch){ log ("jimey - Channel Deleted - $secUrl") return null } liveMatcher = srcUrl_text =~ "value='file=(.*?)&.*?" if(!liveMatcher){ println "No Playpath in " + srcUrl log("No Playpath in " + srcUrl) return } secCode = liveMatcher [0][1] rtmpUrl = "rtmpe://64.191.80.10/edge playpath=" + secCode + " swfurl=http://jimey.tv/player/fresh.swf pageUrl=http://www.jimey.tv live=1" } } else { def idMatcher = linkTitle =~ '(?s)YYCAST_EMBED_ID -->.*?-->.*?javascript">.*?fid="(.*?)"' def idMatch = linkTitle ==~ '(?s).*?YYCAST_EMBED_ID -->.*?-->.*?javascript">.*?fid=".*?".*?' if (!idMatch){ idMatcher = linkTitle =~ '(?s)javascript["\']>\\s?fid=["\'](.*?)["\']' idMatch = linkTitle ==~ '(?s).*?javascript["\']>\\s?fid=["\'].*?["\'].*?' if (!idMatch){ idMatcher = linkTitle =~ '(?s)