Advertisement
Guest User

ContentScraper

a guest
Dec 28th, 2014
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.46 KB | None | 0 0
  1. # This script scrapes a web streaming site, presents the show list, and then streams the content directly from the back-end CDN.
  2. # It's currently hard-set to "Adventure Time".
  3.  
  4.  
  5.  
  6. $player = 'C:\Program Files (x86)\VideoLAN\VLC\vlc.exe'
  7.  
  8. $TargetShow = "rick-and-morty"
  9. $genre = "cartoons"
  10. #$Genres = @("anime","cartoons","movies","ova")
  11.  
  12. #foreach ($genre in $genres) {
  13. #$genre = "anime"
  14. #$content = invoke-webrequest "http://www.watchcartoononline.com/$genre-list/"
  15. #$ShowRegex = [regex]$( ".*(http.*\/" + $genre + ".*)`"" ).tostring()
  16. #$($content.AllElements | ?{$_.tagname -eq "LI"} | select -expand innerhtml | select-string -pattern $ShowRegex).matches.groups.captures.value |?{$_ -notmatch "href"}}
  17.  
  18.  
  19. $MainUrl = "http://www.watchcartoononline.com/$genre/$targetShow"
  20. [System.Reflection.Assembly]::LoadWithPartialName("System.web")
  21. [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
  22. [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
  23.  
  24. function GetList($MainUrl){
  25. Write-host "Grabbing first WebRequest: $mainurl"
  26. $content = invoke-webrequest $MainUrl -TimeoutSec 11 -ErrorAction Stop
  27. $URLList = $($content.AllElements | ?{$_.tagname -eq "LI"} | select -expand innerhtml | select-string -pattern ".*(http.*)`"").matches.groups.captures.value | ?{$_ -match ("^http.*" + $targetshow + ".*")} | select -unique
  28. return $URLList
  29. }
  30.  
  31. $UrlList = GetList $MainUrl
  32. $showList = $urllist -replace "(http:\/\/.*\/)|($targetshow-)",""
  33. out-file .\showlist.txt -InputObject $showlist -force
  34. start .\showlist.txt
  35.  
  36. function WatchShow ($url, [switch]$watchnow, $ShowName) {
  37. write-host $url
  38. $content = invoke-webrequest $url -TimeoutSec 9
  39.  
  40. $PlayerURL = $($content.content | select-string -pattern ".*(http:\/\/.*flv).*").matches.groups[1].value
  41. $content = invoke-webrequest $PlayerURL -body "fuck_you=&confirm=Click+Here+to+Watch+Free%21%21" -method post
  42. $RawFileURL = $($content.content | select-string -pattern ".*file.*(http.*flv).*").matches.groups[1].value
  43. $DecodedFileUrl = [system.web.httputility]::UrlDecode($RawFileUrl)
  44. $EncodedFileUrl = $([system.uri]$DecodedFileUrl).absoluteURI
  45. $filepathy = "`"$pwd\$TargetShow`-$ShowName.flv`""
  46. write-host "Wgetting: $encodedfileurl"
  47. $WgetArguments = @{argumentlist = "/k wget.exe -c `"$encodedfileurl`" -O $FilePathy"}
  48. if (-not $watchnow) {$WgetArguments += @{wait=$true}}
  49. if (-not (test-path $filepathy)) {start-process "cmd.exe" @WGetarguments}
  50. if ($watchnow){
  51. sleep 10
  52. start-process $player -argumentlist "`"$filepathy`""
  53. }
  54. }
  55.  
  56.  
  57.  
  58. function downloadall($urllist) {
  59. $urllist | %{watchShow "$_"}
  60. }
  61. function watchone($word) {
  62. $ShowUrl = "$($urllist -match "$word" | select -unique -first 1)"
  63. watchshow $ShowUrl -watchnow $word
  64. }
  65.  
  66.  
  67. function Return-DropDown {
  68. $Choice = $DropDown.SelectedItem.ToString()
  69. watchone $choice
  70. }
  71. Function DropDown($List){
  72. [array]$DropDownArray = $List
  73. $i=0;$DropDownArray |%{if ($_.length -gt $i) {$i = $_.length}}
  74. write-host $i
  75. $Form = New-Object System.Windows.Forms.Form
  76. $Form.width = ($i*8)
  77. $Form.height = 150
  78. $Form.Text = ”Watch”
  79. $DropDown = new-object System.Windows.Forms.ComboBox
  80. $DropDown.Location = new-object System.Drawing.Size(30,10)
  81. $DropDown.Size = new-object System.Drawing.Size(($i*6),$i)
  82. ForEach ($Item in $DropDownArray) {$DropDown.Items.Add($Item)}
  83. $Form.Controls.Add($DropDown) | out-null
  84.  
  85.  
  86. $DropDown2Array = @("Cartoons";"Anime";"Movies")
  87.  
  88. $DropDown2 = new-object System.Windows.Forms.ComboBox
  89. $DropDown2.Location = new-object System.Drawing.Size(30,10)
  90. $DropDown2.Size = new-object System.Drawing.Size(($i*6),$i)
  91. ForEach ($Item in $DropDown2Array) {$DropDown2.Items.Add($Item)}
  92. $Form.Controls.Add($DropDown2) | out-null
  93.  
  94. $DropDownLabel = new-object System.Windows.Forms.Label
  95. $DropDownLabel.Location = new-object System.Drawing.Size(10,10)
  96. $DropDownLabel.size = new-object System.Drawing.Size(100,20)
  97. $DropDownLabel.Text = $args
  98. $Form.Controls.Add($DropDownLabel)
  99. $Button = new-object System.Windows.Forms.Button
  100. $Button.Location = new-object System.Drawing.Size(100,50)
  101. $Button.Size = new-object System.Drawing.Size(100,20)
  102. $Button.Text = "OK"
  103. $Button.Add_Click({Return-DropDown})
  104. $form.Controls.Add($Button)
  105. $Form.Add_Shown({$Form.Activate()})
  106. $Form.ShowDialog()
  107. };
  108.  
  109. dropdown $showlist
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement