[Release] Stupid simple 3ds python tools

Discussion in '3DS - Homebrew Development and Emulators' started by froatsnook, Nov 24, 2014.

  1. froatsnook
    OP

    froatsnook Advanced Member

    Newcomer
    71
    49
    Mar 18, 2014
    United States
    As much as I like you guys, I try to avoid downloading random binaries to manage 3ds files as much as possible. I wrote a couple python scripts with the goal doing common tasks via drag and drop in windows explorer. They work for me. Maybe they'll work for you.

    At the moment I have python 3.4 installed. They might work with older pythons but I haven't tested it. For python 2.x, at least a future print function import would be necessary. If there's any interest I'll fix them up.

    rename.py:
    Choose your file name format near the top of the file (mine is
    Code:
    target_format = "{id} - {name} {region} {filename}"
    ). Then drag and drop roms onto it. It will download the latest XML from 3ds.essh.co when it doesn't recognize a rom.

    crc.py:
    Drag and drop a rom onto it and it will print its CRC in the console. Useful for verifying untrimmed roms.

    trim.py:
    untrim.py:
    Here you need rom_tool.exe in your path (or in the same directory as (un)trim.py). Drag and drop to trim, or drag and drop to untrim. The file is modified in place. But according to rom_tool.exe, it's a lossless operation so that shouldn't be an issue.

    rename_save.py:
    Drag a save file to rename from 0004000000XXXXXX.sav to something readable. Drag it back to change it back. Since titleids aren't unique (e.g. Pokemon X), you might see the wrong release name/id (but it should be sufficient for figuring out what game it is). I didn't test it on too many saves, so let me know if it doesn't work for some game.
     

    Attached Files:

  2. Timburpton

    Timburpton GBAtemp Advanced Fan

    Member
    591
    133
    Nov 18, 2014
    Do you think can auto extra title id and rename the .sav file with titleid to rom file name?
     
  3. froatsnook
    OP

    froatsnook Advanced Member

    Newcomer
    71
    49
    Mar 18, 2014
    United States
    What?

    Do you mean rename 00040000000XXXXX.sav to Pokemon.sav or whatever?
     
  4. Timburpton

    Timburpton GBAtemp Advanced Fan

    Member
    591
    133
    Nov 18, 2014
    Yes. For example auto rename 000040000000.sav to Pokemon_Omega.sav when detect Pokemon_omega.3ds titleid as 000040000000
     
  5. froatsnook
    OP

    froatsnook Advanced Member

    Newcomer
    71
    49
    Mar 18, 2014
    United States
    Yeah I could do that. I might have time tonight :).
     
  6. Timburpton

    Timburpton GBAtemp Advanced Fan

    Member
    591
    133
    Nov 18, 2014
    Thank you so much. Auto rename other way round will be much thank you too.
     
  7. froatsnook
    OP

    froatsnook Advanced Member

    Newcomer
    71
    49
    Mar 18, 2014
    United States
    I uploaded a new version. I hope it's helpful.
     
  8. Timburpton

    Timburpton GBAtemp Advanced Fan

    Member
    591
    133
    Nov 18, 2014
    The script work great after update python 3.4.2. It no work 2.7.8.

    One other thing, how I modify rename.py so it'll rename format to Pokemon_X_USA.3ds instead of the 250 - Pokemon X - USA -AEVAD.3ds
     
  9. froatsnook
    OP

    froatsnook Advanced Member

    Newcomer
    71
    49
    Mar 18, 2014
    United States
    First change target_format (top of file):

    Code:
    target_format = "{name}_{region}"
    
    then you have to change sanitize_for_file_name (line 245). Something like this:
    Code:
    def sanitize_for_file_name(text):
        text = text.replace(": ", "_")
        text = text.replace(":", "_")
        text = text.replace(" ", "_")
        text = text.replace("!", "")
        text = text.replace("?", "")
        return text
    
     
  10. Timburpton

    Timburpton GBAtemp Advanced Fan

    Member
    591
    133
    Nov 18, 2014
    Thanks! That works!

    I checked your python script and it retrieves the xml from 3ds.essh.co. Some titles not show up like some eshop games. Any way to add them? I think can edit titles.xml but your script fetches the title.xml each time.
     
  11. froatsnook
    OP

    froatsnook Advanced Member

    Newcomer
    71
    49
    Mar 18, 2014
    United States

    Is it just new stuff that isn't showing up?
     
  12. Timburpton

    Timburpton GBAtemp Advanced Fan

    Member
    591
    133
    Nov 18, 2014
    For example denpamen does not show up and it's not that new
     
  13. froatsnook
    OP

    froatsnook Advanced Member

    Newcomer
    71
    49
    Mar 18, 2014
    United States
    Do you mean 'THE "DENPA" MEN: They Came By Wave USA'? That is on 3ds.essh.co. Maybe you just need to remove the quotes in the file name:

    Code:
    def sanitize_for_file_name(text):
        text = text.replace(": ", "_")
        text = text.replace(":", "_")
        text = text.replace(" ", "_")
        text = text.replace("\"", "")
        text = text.replace("!", "")
        text = text.replace("?", "")
        return text
    
     
  14. Timburpton

    Timburpton GBAtemp Advanced Fan

    Member
    591
    133
    Nov 18, 2014
    This work good. Much thanks.
     
  15. pattho

    pattho Newbie

    Newcomer
    6
    0
    Apr 6, 2015
    United States
    Excellent!
    Thank you very much, was messing with the weird gui binaries with little luck and this did exactly the things I needed
     
  16. froatsnook
    OP

    froatsnook Advanced Member

    Newcomer
    71
    49
    Mar 18, 2014
    United States
    I'm glad it was useful :).
     
  17. cearp

    cearp the ticket master

    Member
    7,555
    4,819
    May 26, 2008
    Tuvalu
    why make a python script for checking the crc? why not just type 'crc32' in terminal if you are going to type out the python command?
    but thanks, a python trimmer can come in handy! although i guess rom_tool would be faster because it is in C. it's hardly a random binary, it's made by 3dsguy and is open source, no need to reinvent the wheel and worry about things
     
  18. pattho

    pattho Newbie

    Newcomer
    6
    0
    Apr 6, 2015
    United States

    Hey froatsnook,
    Can you make a python script to replace private headers in the sky3ds template? They distribute an executable but would prefer python but I dont know how to do it

    https://docs.python.org/2/library/string.html

    Basically the 16 groups of two characters (hex bytes) above the 48 groups of FF need to be replaced by your private set of 16 hex bytes

    Here is a snipit from sky3ds latest template.txt

    Code:
    ** : KTR-P-CAFJ
     
    SHA1: 2136BBF38844407133927BA84F567B4C0E814A63
    00 00 00 00 C2 F0 02 90 C2 22 13 00 9E 23 61 DC
    43 54 52 49 4D 41 47 45 00 00 00 00 00 00 00 00
    E8 00 55 6E DC 52 75 E0 B8 72 57 D4 2A 1F F7 89
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    4B 54 52 2D 50 2D 43 41 46 4A 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 DA 6D
     
     
    ** : KTR-P-CAFP
     
    SHA1: 7DB6EE2B8C06649D31AA2D5A69E05653722BE4E4
    00 00 00 00 C2 F0 02 90 C2 22 13 00 E0 83 1F 7C
    43 54 52 49 4D 41 47 45 00 00 00 00 00 00 00 00
    72 29 98 09 08 8C 64 A6 1D D0 41 E5 FF 92 65 17
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    4B 54 52 2D 50 2D 43 41 46 50 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 BA 6F 
    So if my private header hex bytes were =
    Code:
    11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF 00

    Then my template.txt would look like the below

    Code:
    ** : KTR-P-CAFJ
     
    SHA1: 2136BBF38844407133927BA84F567B4C0E814A63
    00 00 00 00 C2 F0 02 90 C2 22 13 00 9E 23 61 DC
    43 54 52 49 4D 41 47 45 00 00 00 00 00 00 00 00
    E8 00 55 6E DC 52 75 E0 B8 72 57 D4 2A 1F F7 89
    11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF 00
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    4B 54 52 2D 50 2D 43 41 46 4A 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 DA 6D
    
     
  19. cearp

    cearp the ticket master

    Member
    7,555
    4,819
    May 26, 2008
    Tuvalu
    i'm pretty sure there already is a python sky tool, made by someone here, did you see/search for it? :)
    -- or, did you see it and it is not what you want?
     
  20. DarkFlare69

    DarkFlare69 GBAtemp Psycho!

    Member
    4,766
    2,621
    Dec 8, 2014
    United States
    Ohio
    I would like this as well