Guest User

download videos

a guest
Jul 28th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # regex for use with newlist
  2. $exclude = $null
  3. #$exclude = 'vidzi'
  4. #$exclude = 'gorillavid'
  5. #$include = 'vodlocker'
  6.  
  7. if ($exclude) { Write-Warning "Sites Being Excluded!: $exclude" }
  8.  
  9. $sites = @(
  10.     'http://thewatchseries.to'
  11.     'http://watchseries.lt'
  12.     'http://watchseriestv.to'
  13.     'http://watchseries.ph'
  14.     'http://watchseries.ag'
  15.     'http://watchtvseries.se'
  16. )
  17.  
  18. $list = @(
  19.     'gorillavid'
  20.     #'filenuke' # mostly file not found
  21.     #'daclips' # mostly file not found
  22.     #'realvid'
  23.     'played'
  24.     #'movpod' # mostly file not found
  25.     'vidzi' # half HD?
  26.     #'allmyvideos' # mostly 1kb vids "wrong ip"
  27.     'vodu' # HD
  28.     'vodlocker' # HD
  29.     'watchfreeinhd' # HD
  30. )
  31.  
  32. function gj { Get-Job | select id, name, state | ft -a }
  33. function sj ($id='*') { Get-Job $id | Stop-Job; gj }
  34. function rj { Get-Job | ? state -notmatch 'run' | Remove-Job; gj }
  35.  
  36. function Remove-InvalidFileNameChars {
  37.     param (
  38.         [Parameter(ValueFromPipeline=$true)]
  39.         [String]$Name,
  40.         [switch]$IncludeSpace
  41.     )
  42.     if ($IncludeSpace) {
  43.         [RegEx]::Replace($Name, "[{0}]" -f ([RegEx]::Escape([String][System.IO.Path]::GetInvalidFileNameChars())), '')
  44.     } else {
  45.         [RegEx]::Replace($Name, "[{0}]" -f ([RegEx]::Escape(-join [System.IO.Path]::GetInvalidFileNameChars())), '')
  46.     }
  47. }
  48.  
  49. $x = 0
  50. function searchsite ($term) {
  51.     $titles = @()
  52.     Write-Host "$($sites[$x])/search/$($term.Replace(' ','%20'))"
  53.     $titles += (iwr "$($sites[$x])/search/$($term.Replace(' ','%20'))").links | select @{n='title';e={$_.title -replace 'watch serie '}}, href | ? {$_.title -and $_.href -match '\/serie\/'} | select -u *
  54.     if ($titles) {
  55.         for ($z=0; $z -lt $titles.count; $z++) {
  56.             Write-Host "$($z+1) $($titles[$z].title)"
  57.         }
  58.         $titles
  59.     }
  60. }
  61.  
  62. $selection = -1
  63. while ($selection -lt 0 -or $selection -gt (@($titles).Count - 1)) {
  64.     $term = ''
  65.     if (!$term) {$term = Read-Host 'Search'}
  66.     if (!$term) {continue}
  67.     Write-Host ''
  68.    
  69.     $titles = ''
  70.     $titles = searchsite $term
  71.     if (!$titles) {continue}
  72.  
  73.     Write-Host ''
  74.     try{ $selection = [int](Read-Host 'Show number') - 1 }catch{}
  75.     Write-Host ''
  76. }
  77.  
  78. $site = $($sites[$x]) + $titles[$selection].href
  79. Write-Host "Site:     $site"
  80. $base = $site -replace '(http://[^\/]+).*', '$1'
  81. $show = $titles[$selection].title
  82. $show = Remove-InvalidFileNameChars $show
  83.  
  84. function regexs {
  85.     $regseason = Read-Host 'Season regex?'
  86.     if ($regseason) {
  87.         $regepisode = Read-Host 'Episode regex?'
  88.         if (!$regepisode) {
  89.             $regepisode = '\d\d?'
  90.         }
  91.     } else {
  92.         $regseason = '\d\d?'
  93.         $regepisode = '\d\d?'
  94.     }
  95.     $regseason
  96.     $regepisode
  97. }
  98.  
  99. function geteps ($regseason, $regepisode) {
  100.     $episodes = (iwr $site).links.href | ? {$_ -match "_s$regseason`_e$regepisode\.html"} | select -u | sort | % {"$base$_"}
  101.     $episodes | sort {$se = $_ -replace '.*_s([0-9][0-9]?)_.*', '$1';if ($se.Length -eq 1) {$se -replace '(.*)', '0$1'}else{$se}}, {$ep = $_ -replace '.*_e([0-9][0-9]?)\..*', '$1';if ($ep.Length -eq 1) {$ep -replace '(.*)', '0$1'}else{$ep}}
  102. }
  103.  
  104. $cont = ''
  105. do {
  106.     $ans = regexs
  107.     $episodes = geteps $ans[0] $ans[1]
  108.  
  109.     Write-Host 'Episode List:'
  110.     $episodes | % {Write-Host $_}
  111.     $cont = Read-Host 'Continue?'
  112. } while ($cont -eq 'n')
  113. Write-Host ''
  114.  
  115. function getinfo ($episode) {
  116.     Write-Host "Episode:  $episode"
  117.     $name = (split-path $episode -leaf) -replace '\..*' -replace '_', ' '
  118.     $season = $name -replace '.*s(\d\d?).*', 'S$1'
  119.     if ($season.Length -eq 2) {$season = $season -replace 's(.*)', 'S0$1'}
  120.     $number = $name -replace '.*e(\d\d?)$', 'E$1'
  121.     if ($number.Length -eq 2) {$number = $number -replace 'e(.*)', 'E0$1'}
  122.     $title = ((iwr $episode).ParsedHtml.title -replace '^.*episode \d\d? -(.*)- watch.*', '$1').Trim()
  123.     $title = $title -replace '\s?online - watchseries\s?|\s?watch online .* season \d{1,2} episode \d{1,2} -\s?|\s?watch series\s?'
  124.     $name = "$show $season$number" + $(if ($title) {" $title"})
  125.     $name = Remove-InvalidFileNameChars $name
  126.     $folder = "$show $season"
  127.  
  128.     @($name, $season, $number, $folder)
  129. }
  130.  
  131. #ps iexplore -ea 0 | stop-process -ea 0
  132. foreach ($episode in $episodes) {
  133.     $array = getinfo $episode
  134.     $name = $array[0]
  135.     $season = $array[1]
  136.     $number = $array[2]
  137.     $folder = $array[3]
  138.     Write-Host "Name:     $name" -fore yellow
  139.    
  140.     $newlist = (iwr $episode).links.href |? {$_ -match '^\/cale'} | select -Unique
  141.     $newlist = $newlist | % { [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($_.Substring($_.IndexOf('=') + 1))) }
  142.     if ($exclude) { $newlist = $newlist | ? {$_ -notmatch $exclude} }
  143.     if ($include) { $newlist = $newlist | ? {$_ -match $include} }
  144.  
  145.     $i = 0
  146.     $x = 1
  147.     $file = $null
  148.     while (!$file) {
  149.         if ($i -eq @($newlist).count) {
  150.             if ($x -eq $sites.Count) {
  151.                 Write-Host 'NOT FOUND' -fore red
  152.                 break
  153.             }
  154.             Write-Host 'NEXT SITE' -fore red
  155.             $i = 0
  156.             $episode = $sites[$x] + ($episode -replace '^.*(/episode.*)', '$1')
  157.             $array = getinfo $episode
  158.             $name = $array[0]
  159.             $season = $array[1]
  160.             $number = $array[2]
  161.             $folder = $array[3]
  162.             $base = $episode -replace '(http://[^\/]+).*', '$1'
  163.             $x++
  164.  
  165.             $newlist = (iwr $episode).links.href |? {$_ -match '^\/cale'} | select -Unique
  166.             $newlist = $newlist | % { [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($_.Substring($_.IndexOf('=') + 1))) }
  167.             if ($exclude) { $newlist = $newlist | ? {$_ -notmatch $exclude} }
  168.             if ($include) { $newlist = $newlist | ? {$_ -match $include} }
  169.  
  170.         }
  171.         $ie = $null
  172.         $prov = $null
  173.         $external2 = $null
  174.         $external2 = @($newlist)[$i]
  175.        
  176.         while (!$external2) {
  177.             if ($i -eq $newlist.count) { break }
  178.             $prov = $newlist[$i]
  179.             try{
  180.                 $external1 = (iwr $episode).RawContent -split "`n" | ? {$_ -match "html.*$prov"} | % {$base + ($_ -replace '^.*href="|" class.*$')} <#| sort -desc#> | select -f 1
  181.                 $external2 = if ($external1) { (iwr $external1).Links.href | ? {$_ -match $prov} }
  182.                 if (!$external2) { $external2 = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($external1.Substring($external1.IndexOf('=') + 1))) }
  183.             }catch{}
  184.             $i++
  185.         } if (!$external2) { continue }
  186.  
  187.         $prov = $external2 | % { $_.substring(7).substring(0, $_.substring(7).indexof('/'))}
  188.         $i++
  189.         Write-Host External: $external2
  190.  
  191.         try {
  192.             $file = .\youtube-dl.exe $external2 -g 2>&1
  193.             if (@($file).count -ne 1) { $file = $null }
  194.         } catch {
  195.             $file = $null
  196.         }
  197.  
  198.         try { [System.Net.WebRequest]::Create($file).getresponse().statuscode | Out-Null } catch { $file = $null }
  199.  
  200.         if (!$file) { continue }
  201.     } if (!$file) { continue }
  202.  
  203.     $ext = $file.substring($file.LastIndexOf('.')) -replace '\?.*$'
  204.  
  205.     Write-Host "Link:     $file"
  206.  
  207.     $dest = "c:\temp\vid\$show\$folder\"
  208.     if (!(Test-Path $dest)) { mkdir $dest | out-null }
  209.    
  210.     Write-Host $dest$name$ext
  211.  
  212.     if (!(Test-Path $dest$name$ext)) {
  213.         Start-Job -Name "$name $prov" -ScriptBlock {param($f, $d, $n, $e, $p) iwr $f -OutFile $d$n$e; Write-Host "$n $p"} -ArgumentList $file, $dest, $name, $ext, $prov | Out-Null
  214.         Write-Host 'DOWNLOADING' -ForegroundColor green
  215.     } else {
  216.         Write-Host 'ALREADY EXISTS' -ForegroundColor Yellow
  217.     }
  218.     Write-Host ''
  219.     #Read-Host 'Press Enter to continue'
  220.     #iwr $file -OutFile $dest$name$ext; write-host "$name $prov"
  221. }
  222.  
  223. sleep 5
  224. while (1) {
  225.     write-host $(gj | ft -a | out-string)
  226.     if (!((get-job).state -match 'run')) {
  227.         Read-Host 'Press Enter to continue'
  228.         break
  229.     }
  230.     sleep 60
  231. }
  232. # Get-Job | ? state -match 'comp' | Remove-Job
Add Comment
Please, Sign In to add comment