Last active
April 25, 2017 04:45
-
-
Save danielewood/38527b6511f538b4960fe91dcdccdf6a to your computer and use it in GitHub Desktop.
Movie-AutoTorrent Scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$CompleteDir = "D:\Movies\" | |
$Files = Get-ChildItem $CompleteDir -Recurse | where {!$_.psiscontainer} | |
$Files | Where Length -LT 400000000 | Where Extension -ne ".srt" | Remove-Item -Verbose -Force | |
$CompleteDir = "D:\Movies\!New Releases" | |
get-childitem $CompleteDir -Recurse | ForEach-Object { Move-Item -LiteralPath $_.FullName $_.FullName.Replace("[",".(") -Force} | |
get-childitem $CompleteDir -Recurse | ForEach-Object { Move-Item -LiteralPath $_.FullName $_.FullName.Replace("]",").") -Force} | |
get-childitem $CompleteDir -Recurse | ForEach-Object { Move-Item -LiteralPath $_.FullName $_.FullName.Replace("..",".") -Force} | |
#$Files | Where {$(Split-Path $_.DirectoryName) -eq $CompleteDir} | Select FullName | |
$Dirs = (Get-ChildItem $CompleteDir -Recurse | where {$_.psiscontainer}).FullName | |
ForEach ($Dir in $Dirs){ | |
$Dir = $Dir.Replace('[','``[') | |
$Dir = $Dir.Replace(']','``]') | |
$Movie = Get-ChildItem $Dir | where Extension -NE '.srt' | |
If (Test-Path "$Dir\*.srt"){ | |
Rename-Item $(Resolve-Path "$Dir\*.srt") "$Dir\$($Movie.Basename).srt" -Verbose -Force | |
} | |
Move-Item "$Dir\*" "$CompleteDir\" -Verbose -Force | |
Remove-Item "$Dir" -Verbose -Force | |
} | |
$Files = (Get-ChildItem $CompleteDir | where {!$_.psiscontainer}).FullName | |
ForEach ($File in $Files){ | |
If ($File -match "HDRIP"){ | |
Move-Item $File "D:\Movies\!In Theaters\" -Verbose -Force | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Definitions | |
#Keeps a list of movies that have been downloaded already so as to not download them twice | |
$DownloadedList = "D:\MovieDownloader\MoviesDownloaded.csv" | |
#Keeps a list of movies that returnd no search results, so to try again next run | |
$Missed = "D:\MovieDownloader\MoviesMissed.csv" | |
#----------Get DVD's released this week----------# | |
$url ='https://www.moviefone.com/dvd/' | |
$response = Invoke-WebRequest -Uri $url | |
#$list = $response.ParsedHtml.body.getElementsByClassName("movie-inner") | select *outerText* | |
$list = $response.ParsedHtml.getElementsByClassName("movie-inner") | select *outerText* | |
#Clean List | |
$movies = @() | |
foreach ($movie in $list){ | |
$line = $movie.outerText -replace "`n",", " -replace "`r",", " | |
$movies += $line | |
} | |
$movies2 = @() | |
foreach ($movie in $movies){ | |
$movie = $movie -replace " , ","" | |
$movie = $movie -replace ",,,,","" | |
$split = $movie.IndexOf(",") | |
$title = $movie.Substring(0, $split) | |
$movies2 += $title | |
} | |
$NewMovies = $movies2 | |
#Convert to system array so I can modify list | |
[System.Collections.ArrayList]$NewMovies = $NewMovies | |
#----------Verify movie is not downloaded already----------# | |
$Downloaded = Import-Csv $DownloadedList -Header "Movies" | |
foreach ($movie in $movies2){ | |
foreach ($Download in $Downloaded){ | |
if ($movie -eq $Download.Movies){ | |
$NewMovies.Remove($movie) | |
} | |
} | |
} | |
#----------Find 1080p Torrent on PirateBay and start download----------# | |
#The URL below for pirate bay limits search to "Movies" | |
#The numbers at the end determine the category to search | |
#This will grab to top download by seeders (some false positives, but usually get agood movie out of it :) | |
foreach ($movie in $NewMovies){ | |
$OGmovie = $movie | |
$movie = $movie + " BRRIP" | |
$movie = $movie -replace " ", "%20" | |
$movie = $movie -replace "\'", "" | |
$movie = $movie -replace "\?", "" | |
$url ="https://thepiratebay.se/search/$movie/0/99/200" | |
$r = Invoke-WebRequest -Uri $url -Method POST | |
sleep -Seconds 1 | |
$data = $r.parsedhtml.getelementsbytagname("TR") | select *innerHTML* | |
if (!$data) { | |
$movie = $movie.Replace("BRRIP","BDRIP") | |
$url ="https://thepiratebay.se/search/$movie/0/99/200" | |
$r = Invoke-WebRequest -Uri $url -Method POST | |
sleep -Seconds 1 | |
$data = $r.parsedhtml.getelementsbytagname("TR") | select *innerHTML* | |
} | |
if (!$data) { | |
$movie = $movie.Replace("BDRIP","BluRay") | |
$url ="https://thepiratebay.se/search/$movie/0/99/200" | |
$r = Invoke-WebRequest -Uri $url -Method POST | |
sleep -Seconds 1 | |
$data = $r.parsedhtml.getelementsbytagname("TR") | select *innerHTML* | |
} | |
if (!$data) { | |
$movie = $movie.Replace("BluRay","1080p") | |
$url ="https://thepiratebay.se/search/$movie/0/99/200" | |
$r = Invoke-WebRequest -Uri $url -Method POST | |
sleep -Seconds 1 | |
$data = $r.parsedhtml.getelementsbytagname("TR") | select *innerHTML* | |
} | |
#Check if no downloads exist for search | |
if ($data) { | |
$Result = $data[1].innerHTML | |
$Magnet = ($Result -split 'magnet" href="')[1] | |
$Magnet = ($Magnet -split '"><IMG alt="Magnet link"')[0] | |
#This loads the magnet link in to your default torrent downloaded (as ling as the association is set) | |
Start "$Magnet" | |
"Downloading $OGmovie" | |
$OGmovie | Add-Content -path $DownloadedList | |
sleep -Seconds 1 | |
} | |
else { | |
"No Search results found for $OGmovie" | |
$OGmovie | Add-Content -path $Missed | |
$NewMissed = Get-Content $Missed | Sort-Object -Unique | |
$NewMissed | Set-Content -Path $Missed | |
} | |
} | |
$NewDownload = Get-Content $DownloadedList | Sort-Object -Unique | |
$NewDownload | Set-Content -Path $DownloadedList | |
sleep 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Definitions | |
#Keeps a list of movies that have been downloaded already so as to not download them twice | |
$DownloadedList = "D:\MovieDownloader\MoviesDownloaded.csv" | |
$Downloaded = Get-Content $DownloadedList | |
$MoviesFolder = 'D:\Movies' | |
$url ="https://thepiratebay.org/search/HDRIP/0/99/201" | |
$r = Invoke-WebRequest -Uri $url -Method POST | |
$data = $r.parsedhtml.getelementsbytagname("TR") | select *innerHTML* | |
#Check if no downloads exist for search | |
if ($data) { | |
for ($i=1; $i -lt 10; $i++){ | |
$Result = $data[$i].innerHTML | |
$Magnet = ($Result -split 'magnet" href="')[1] | |
$Magnet = ($Magnet -split '"><IMG alt="Magnet link"')[0] | |
#$Magnet | |
$Title = ($Result -split 'A title="Details for ')[1] | |
$Title = ($Title -split '" class=detLink href')[0] | |
#$Title | |
If ($Downloaded -notcontains $Title){ | |
If (!(Get-ChildItem -Recurse $MoviesFolder | where Length | Where Name -match "$(($Title -split '.20')[0])")){ | |
#This loads the magnet link in to your default torrent downloaded (as long as the association is set) | |
Start "$Magnet" | |
Write-Host "Downloading $Title" | |
} | |
Else { | |
Write-Warning "$Title already exists" | |
} | |
$Title | Add-Content -path $DownloadedList | |
} | |
Else { | |
Write-Host "Already downloaded $Title" | |
} | |
} | |
} | |
sleep 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment