Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Sakat's CoC Script - Download your clan data and CWL stats

  1. #1

    [Sakat's CoC Script] Tool to download your clan and CWL stats

    Hey Clash-mates,


    I've just finished to write a script in Python that automatically downloads the data of your clan as well as your members stats (stars & percent done/taken) during a CWL season.




    Remark:
    - You can directly copy-paste the data downloaded by the script in our CWL Planning sheet. See below for the links.
    - The script is written in Python 3, you can check the source code on Github: https://github.com/Sakatland/SCS
    - Please also notice that this script is based on ClashOfClansAPI (1.0.4) by Tony Benoy. For more info, please check his github.



    How to use it:

    For the script to work properly you need:

    * Your own API token (added in Token.txt)
    * Run the script during CWL (for option #4)
    * Prepare Warlogs.txt (for option #5)
    * An internet connection



    1) Download SCS:

    The Sakat's CoC Script is available on Github, you can download it here:
    There are four files in "SCS.zip": SCS.exe (the script), Token.txt (required), Wartags.txt (optional, see instructions below) and Readme.txt (some info).



    2) Run the script:

    1. To be able to download data from the API, you need to have your own Token:
    - Open https://developer.clashofclans.com/
    - Register
    - Click on your account
    - Create New Key
    - Enter Key Name (doesn't matter), Description (doesn't matter) and your IP
    - Copy-paste your key into Token.txt (without space char before or after)

    Remark:

    - If you don't know your IP go to whatismyip.com
    - Your API token is linked to your IP, so when your IP changes you need to create a new one

    2. Run the script ("SCS v0.6.exe")

    3. Follow instructions of the script:
    - Enter your clantag (for ex. "#ABCDEF")
    - Select the data you want to download

    Remark:
    - The data about current CWL group are only available when a CWL season is taking place and before a new clanwar is launched (once the CWL season is over).
    - The tags of CWL wars are available only once the preparation phase started (before the preparation it will be written #000000000 so will be ignored).
    - To download the individual details of older CWL wars, you need to prepare Warlogs.txt with its 28 wartags in it (see the example file).



    3) The .txt files:

    Depending on the options selected, the script will generate up to 9 .txt files. Most of them are used to store the raw data as downloaded from the API (dictionary synthax) and so not really "human friendly". So:

    - File #08: This is the most important file where all the information are properly written. You will find here the names and tags of opponent clans, the wartags of your clan and the individual stats of your members (selected for the CWL season). For the last one, the synthax is the following: stars done, percentage done, star taken, percentage taken. To see these data even better, you can copy-paste them in Excel or in our CWL Planning Sheet (see below).

    - Wartags.txt: If you run the script during the last CWL war, it will auto-generate Wartags.txt. It's a good idea to save this file somewhere else in case you want to re-download the stats of these wars later (even when no CWL season is taking place).

    - File #05: In this file you can see the wartags for the 28 wars, the script also indicates when your clan is in the war.




    I hope you will find it useful. Don't hesitate if you have any feedback or idea to improve it!



    Sakat (#QRLJ0GLJ)
    Clan Valais (#9PJYL)



    ====> Check our other projects <====

    - CGLeech.tk, a tool to keep the history of your clan and members activity in Clan Games:

    - CWL Planning, a Google Sheet designed to help clan leaders to organize clan wars that are part of the Clan War League (CWL).
    Last edited by Sakat; February 25th, 2019 at 07:47 AM.
    Tired of Clan Games Leechers? Follow your clan member activity with CGLeech !
    ===>More info on the official thread <===



  2. #2
    Update (09.04.2019):
    - Human readable text outputs with clan average stats in .txt file 01, 02 & 08
    - Multiple Bug fix (player with single quote char in the name, clantage not written in capital, players attacked several times in CWL, ...)


    Update
    (25.02.2019):
    - I compile the script into a .exe to simplifiy the use of the script (tested on Windows 7-8-10)
    - Several bugs fix
    - Token must now be entered in Token.txt
    Last edited by Sakat; April 9th, 2019 at 02:46 PM.
    Tired of Clan Games Leechers? Follow your clan member activity with CGLeech !
    ===>More info on the official thread <===



  3. #3
    Another topic reserved for future content
    Tired of Clan Games Leechers? Follow your clan member activity with CGLeech !
    ===>More info on the official thread <===



  4. #4
    Version 0.6 released!

    I compiled the Python script in a .exe that can be used directly without the need to install a Python terminal. You just need to add your token for the API in Token.txt and run the script. The source-code stays available on Github.

    This new version also fixes several bugs.
    Last edited by Sakat; February 25th, 2019 at 07:54 AM.
    Tired of Clan Games Leechers? Follow your clan member activity with CGLeech !
    ===>More info on the official thread <===



  5. #5
    This is great. It's really fun playing around with this data. I created https://www.clashleaders.com/ and also started with doing some Python code. Then I realized no one really is going to download a script to get their data. So I converted to a website and then eventually used Panda's Dataframes to convert the data to excel. I used to have the website as open source but have moved it to a private repository since traffic has picked up.

    Send me a message if you ever want to collaborate. I haven't had much time to work on anything new. Great to see other Python lovers.
    Last edited by amir20; April 8th, 2019 at 06:49 PM.

  6. #6
    Update (09.04.2019):
    - Human readable text outputs with clan average stats in .txt file 01, 02 & 08
    - Multiple Bug fix (player with single quote char in the name, clantage not written in capital, players attacked several times in CWL, ...)
    Last edited by Sakat; April 9th, 2019 at 02:46 PM.
    Tired of Clan Games Leechers? Follow your clan member activity with CGLeech !
    ===>More info on the official thread <===



  7. #7
    Hi Sakat,
    Thank you for your great work on this project.
    I tried your python script and got some files but the format is single quoted, so it cannot be used in pandas dataframes.
    Could you please help me in changing this as when I try API directly on the SUpercell site there are double-quote (true json)? Thanks!!

  8. #8
    Quote Originally Posted by omanoe View Post
    I tried your python script and got some files but the format is single quoted, so it cannot be used in pandas dataframes. Could you please help me in changing this as when I try API directly on the SUpercell site there are double-quote (true json)? Thanks!!
    Hey, thanks for your feedback!
    The API is giving double-quotes data but in Python when the Request/JSON method is used, it isn't a true json file anymore. If I refer to the following post on stackoverflow: "...is not intended to be valid JSON but rather valid JSON transformed into Python data structures and types" (https://stackoverflow.com/questions/...s-single-quote)

    I don't know if there is a better way to achieve this. I'm really a beginner in Python.
    Tired of Clan Games Leechers? Follow your clan member activity with CGLeech !
    ===>More info on the official thread <===



  9. #9
    Tank you for your interesting reply, even if you are a beginner.
    I'm begginer too
    What I noticed in your link, is that at the end, glmrenard said that there is a way to get it in right json :
    jsonresponse=json.dump(requests.get(xxx).json())

    I didn't tried it but it's worth testing
    Cheers
    Last edited by omanoe; April 12th, 2019 at 12:56 PM.

  10. #10
    Quote Originally Posted by omanoe View Post
    What I noticed in your link, is that at the end, glmrenard said that there is a way to get it in right json :
    jsonresponse=json.dump(requests.get(xxx).json())
    I saw the message too but actually the json request is done in ClashOfClansAPI (https://github.com/tonybenoy/cocapi), that I'm using, so I'm not sure how it works.
    Last edited by Sakat; April 13th, 2019 at 04:17 AM.
    Tired of Clan Games Leechers? Follow your clan member activity with CGLeech !
    ===>More info on the official thread <===



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •