PowerShell script to download mtggoldfish decks automaticly
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
PowerShell script to download mtggoldfish decks automaticly
by Repeperilka » 28 Nov 2017, 15:53
Hello there.
I want to share with you a little script I made that downlads decks from the metagame page of mtggoldfish and creates a .dck file ready to be played in Forge.
DISCLAIMER: If you want to run it on a pc that is not Win10, you'll have to download PowerShell 3.0 (and I don't know how to do it, so this tuto will be for Windows 10 users)
HOW TO INSTALL IT
1: Search in your system (or ask Cortana) for a application called "Windows PowerShell ISE", and run it.
2: In the down window with a blue background type "Set-ExecutionPolicy RemoteSigned"(without "") and press Enter. This will only let you run scripts created by your pc, to prevent other people to run scripts you dont want.
3: In the white window where you can type, copy this:
HOW TO USE IT1: Right click the archive you've just created, and select "run with Powershell"
2: It will ask you for a format, you just have to type the format you want like it says in the parenthesis, but only one of them. Then press Enter.
3: Now you can type a prefix and press Enter, for example if I type "GF metagame" (without "") and I'm downloading a deck called "Affinity", the final name of the deck will be "GF metagame Affinity"
4: Sit down and let it do its magic. When the script is over, it will close automaticly.
I want to share with you a little script I made that downlads decks from the metagame page of mtggoldfish and creates a .dck file ready to be played in Forge.
DISCLAIMER: If you want to run it on a pc that is not Win10, you'll have to download PowerShell 3.0 (and I don't know how to do it, so this tuto will be for Windows 10 users)
HOW TO INSTALL IT
1: Search in your system (or ask Cortana) for a application called "Windows PowerShell ISE", and run it.
2: In the down window with a blue background type "Set-ExecutionPolicy RemoteSigned"(without "") and press Enter. This will only let you run scripts created by your pc, to prevent other people to run scripts you dont want.
3: In the white window where you can type, copy this:
- Code: Select all
cls
$formats = Read-Host -Prompt '¿Which format do you like to download? (modern, legacy, vintage, standard, pauper, frontier, commander, commander_1v1 or tiny_leaders)'
cls
$prefixname = Read-Host -Prompt 'Set a prefix for the decks names'
cls
$sideboard = "Sideboard"
$scriptpath = $MyInvocation.MyCommand.Path
$dir = Split-Path $scriptpath
Write-host "My directory is $dir"
$url = "https://www.mtggoldfish.com/metagame/$formats/full#paper"
echo $url
$html = Invoke-WebRequest $url
$mainDeck = $html.parsedhtml.getElementsByClassName("archetype-tile")
echo $mainDeck.length
$e=0
do{
$sUrl = "https://www.mtggoldfish.com/archetype/$($mainDeck[$e].id)"
echo $sUrl
$shtml = Invoke-WebRequest $sUrl
$smainDeck = $shtml.parsedhtml.getElementsByTagName("input") | Where{ $_.name -eq "deck_input[deck]" }
$deck = $smainDeck.value
$deck = $deck -split '\n'
$nmainDeck = $shtml.parsedhtml.getElementsByClassName("deck-view-title")
$nname = $nmainDeck[0].innerText
$fullname = $nname.Substring(0,$nname.Length-23)
$fullname = $fullname.replace("/", "")
$tfullname = "$prefixname $fullname"
$deckFile = "[metadata]`nName=$tfullname`n[Main]"
$n =0
do{
if ($deck[$n][0] -eq 's'){
$deckFile = "$deckFile`n[Sideboard]"
}else{
$deckFile = "$deckFile`n$($deck[$n])"
}
$n +=1
}while($n -le $deck.Length - 2)
$deckFile = $deckFile.ToString()
$deckFile | Out-File "$dir\$tfullname.dck" -encoding ascii
$e += 1
}while ($e -le $mainDeck.length)
HOW TO USE IT1: Right click the archive you've just created, and select "run with Powershell"
2: It will ask you for a format, you just have to type the format you want like it says in the parenthesis, but only one of them. Then press Enter.
3: Now you can type a prefix and press Enter, for example if I type "GF metagame" (without "") and I'm downloading a deck called "Affinity", the final name of the deck will be "GF metagame Affinity"
4: Sit down and let it do its magic. When the script is over, it will close automaticly.
- Repeperilka
- Posts: 5
- Joined: 19 Nov 2017, 05:12
- Has thanked: 1 time
- Been thanked: 2 times
Re: PowerShell script to download mtggoldfish decks automati
by siyiye » 05 Dec 2017, 03:15
thx!!!
Nice script!
Nice script!
Re: PowerShell script to download mtggoldfish decks automati
by 5enza » 19 Jun 2018, 13:05
Great script nice job!
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 82 guests