Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [System.Reflection.Assembly]::LoadWithPartialName("System.web")
- [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
- [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
- $mainurl = "http://www.animeflavor.com"
- $urls = @{}
- $episodes = @{}
- Function GetList($MainUrl){
- Write-host "Grabbing first WebRequest: $mainurl"
- $content = invoke-webrequest $MainUrl -TimeoutSec 11 -ErrorAction Stop
- $URLList = $($content.AllElements | ?{$_.tagname -eq "LI"} | select -expand innerhtml | select-string -pattern ".*(http.*)`"").matches.groups.captures.value | ?{$_ -match ("^http.*" + $targetshow + ".*")} | select -unique
- return $URLList
- }
- Function WatchShow ($episodeUrl, $ShowName, $EpisodeName, [switch]$watchnow) {
- $content = invoke-webrequest -uri "$mainurl/$episodeUrl" -TimeoutSec 9
- $nextUrl = $content.RawContent | select-string -Pattern "`"(?<url>\/nan\/.+php)`"" | %{$_.matches.captures.groups[1].value}
- $content = invoke-webrequest -uri "http://www.animeflavor.com$nextUrl"
- $fileUrl = $content.scripts | ? innerHTML -match "afplayer" | select -expand innerHTML | select-string -Pattern "file.*(?<url>http.+)`'" |%{ $_.matches.captures.groups[1].value}
- $filepathy = "`"$pwd\$EpisodeName.flv`""
- write-host "Wgetting: $encodedfileurl"
- $WgetArguments = @{argumentlist = "/c wget -c `"$fileUrl`" -O $FilePathy"}
- if (-not $watchnow) {$WgetArguments += @{wait=$true}}
- if (-not (test-path $filepathy)) {start-process "cmd.exe" @WGetarguments}
- if ($watchnow){
- sleep 10
- start-process $player -argumentlist $filepathy
- }
- }
- Function WatchEpisode() {
- $EpisodeName = $Global:EpisodeCombo.SelectedItem
- $showName = $Global:ShowCombo.SelectedItem
- $episodeUrl = $episodes[$EpisodeName]
- WatchShow $episodeUrl $showName $EpisodeName -watchnow
- }
- Function Form([array]$Size, $Text) {
- $Form = New-Object System.Windows.Forms.Form
- $Form.width = $Size[0]
- $Form.height = $Size[1]
- $Form.Text = $Text
- $Form.AutoSize = $True
- $Form.AutoSizeMode = "GrowAndShrink"
- Return $Form
- }
- Function Click ($selection) {WatchOne $selection}
- Function GetShowList() {
- $Genre = $Global:GenreCombo.selectedItem
- $content = Invoke-WebRequest -uri "$mainurl/$genre"
- $($content.ParsedHtml.getElementById("postareainner")).getElementsByTagName("a") | %{$urls.add($_.innerText,$_.pathname)}
- $Global:ShowCombo.Items.Clear()
- $urls.keys | sort | % {$Global:ShowCombo.Items.Add($_) | Out-Null}
- $Global:ShowCombo.Enabled = $True
- }
- Function GetEpisodeList() {
- $Global:Show = $Global:ShowCombo.SelectedItem
- $showUrl = $urls[$Global:Show]
- write-host "$mainurl/$showUrl"
- $content = Invoke-WebRequest -uri "$mainurl/$showUrl"
- $($content.ParsedHtml.getElementsByTagName("div") | ? IHTMLELEMENT_classname -eq "book-navigation").getElementsByTagName("a") | %{$episodes.add($_.innerText,$_.pathname)}
- $Global:EpisodeCombo.Items.Clear()
- $episodes.keys | sort | % {$Global:EpisodeCombo.Items.Add($_) | Out-Null}
- $Global:EpisodeCombo.Enabled = $True
- }
- Function DropDown($Form, [Array]$Size, [Array]$Location, $List, $Action, $Enabled){
- $DropDown = new-object System.Windows.Forms.ComboBox
- $DropDown.Location = new-object System.Drawing.Size($Location[0],$Location[1])
- $DropDown.Size = new-object System.Drawing.Size($Size[0],$Size[1])
- ForEach ($Item in $List) {$DropDown.Items.Add($Item) | Out-Null}
- $DropDown.Add_SelectedIndexChanged($Action)
- $DropDown.Enabled = $Enabled
- $Form.Controls.Add($DropDown)
- Return $DropDown
- }
- $Genres = @("cartoons","anime")
- $Player = 'C:\Program Files (x86)\VideoLAN\VLC\vlc.exe'
- #(width/height) (X/Y)
- $Global:Form = Form @(100,150) "Watch!"
- $Global:GenreCombo = DropDown $Global:Form @(300,1) @(30,30) $Genres {GetShowList} $True
- $Global:ShowCombo = DropDown $Global:Form @(300,1) @(30,50) @() {GetEpisodeList} $False
- $Global:EpisodeCombo = DropDown $Global:Form @(300,1) @(30,70) @() {WatchEpisode} $False
- $Global:Form.Add_Shown({$Global:Form.Activate()})
- $Global:Form.ShowDialog()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement