Skip to content

Instantly share code, notes, and snippets.

@davidruhmann
Created December 19, 2014 01:15
Show Gist options
  • Save davidruhmann/7867198cfeb393957c8d to your computer and use it in GitHub Desktop.
Save davidruhmann/7867198cfeb393957c8d to your computer and use it in GitHub Desktop.
[Batch] [Powershell] IMDB Info Retriever
@echo off
:Main <Title> [Destination=CD]
call :DownloadIMDB %1 %2 "%CD%"
exit /b
:DownloadIMDB <Title> <Destination> ~UI/IO
PowerShell -NoProfile -ExecutionPolicy RemoteSigned -Command "$c = New-Object System.Net.WebClient; $c.DownloadString('http://www.omdbapi.com/?t=%~1&plot=full&r=json').Split(',') | ForEach { $_.Split('{') | ForEach { $_.Split('}') | ForEach { $l = $_.ToLower(); If ($l.Contains(([char]0x0022).ToString() + 'title' + ([char]0x0022).ToString())) { $env:_title = $_.Split(([char]0x0022).ToString())[3] } ElseIf ($l.Contains(([char]0x0022).ToString() + 'year' + ([char]0x0022).ToString())) { try { $env:_year = $_.Split(([char]0x0022).ToString())[3].Substring(0,4) } catch { } } ElseIf ($l.Contains(([char]0x0022).ToString() + 'poster' + ([char]0x0022).ToString())) { $env:_poster = $_.Split(([char]0x0022).ToString())[3] } ElseIf ($l.Contains(([char]0x0022).ToString() + 'rated' + ([char]0x0022).ToString())) { $env:_rated = $_.Split(([char]0x0022).ToString())[3] } } } }; Write-Host "$env:_title ($env:_year)"; Write-Host "$env:_rated"; $c.DownloadFile($env:_poster, '%~2\' + $env:_title + ' (' + $env:_year + ').jpg');"
exit /b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment