Jump to content
Korean Random
Aslain

How to make this scripts work? (clanicons downloader)

Recommended Posts

Hi,

 

So you guys have developed this: https://bitbucket.org/XVM/xvm/src/31bfce2b2c96/addons/clanicons/?at=default

 

But it seem to be outdated, I cannot make it work at all. In windows it's downloading icons super slow, and nothing is created, I receive 0 bytes files and no icons at all.

 

What I want to do is to download is all clan icons for every region.

 

Any help appreciated.

 

Ty.

Edited by Aslain

Share this post


Link to post

Short link
Share on other sites

I found out that clanicon location for eu is now:

http://eu.wargaming.net/clans/media/clans/emblems/cl_001/500000001/emblem_64x64.png
So Should this work if host=eu.wargaming.net ? (modified scripts-allclans\.update.sh)

#!/bin/sh

[ "$host" = "" ] && exit

# main
main()
{
  id=$startclan
  mkdir -p ../icons/$dir/
  echo "Started at `date +%T_%F`"
  while [ $id -le $lastclan ]; do
    update $id
    id=$((id+1))
  done
  optimize
  echo "Finished at `date +%T_%F`"
}

# update
# $1 - clanId
update()
{
  echo -n "$1 - "

  errors=0
  while [ 1 ]; do
    clan=`wget -qc -t 5 -T 10s "http://$host/clans/$1/" -O - 2>/dev/null | \
          grep "<title>" | \
          cut -d[ -f2 | \
          cut -d] -f1`

#Clan removed or does not exist
    if [ "$clan" = "    <title>" ]; then
      echo "REMOVED"
      return
#Error handling - server maintenance
    elif [ "$clan" = "" ]; then
      errors=$((errors+1))
      if [ $errors -lt 2 ]; then
        echo -n "EMPTY `date +%T_%F` $errors.. "
        sleep 10m
        continue
      elif [ $errors -lt 6 ]; then
        echo -n "$errors.. "
        sleep 10m
        continue
      else
        echo "ERROR"
        return
      fi
    fi
    break
  done

  echo -n "[$clan] => $clan.png"
  wget -qc -t 5 -T 10s http://$host/clans/media/clans/emblems/cl_${1:(-3)}/$1/emblem_64x64.png \
       -O ../icons/$dir/$clan.png 2>/dev/null

  echo " OK"
}

optimize()
{
  echo "Optimizing PNGs..."
  (
    cd ../icons/$dir
    pngoptimizer -file:*.png
  )
}

 

EDIT: Doesnt work for me as it is. I think it hangs when getting from clanname from <title> for the $clan as the format of title has changed? Im not much of a coder myself so im not sure....

 

clan=`wget -qc -t 5 -T 10s "http://$host/clans/$1/" -O - 2>/dev/null | \
          grep "<title>" | \
          cut -d[ -f2 | \
          cut -d] -f1`
Edited by Okxa

Share this post


Link to post

Short link
Share on other sites

Made a working update.sh!

This Works atleas for me on git for windows, i had to download wget because git for win doesnt have it.

 

And works on EU, but havent tested for other regions

Also be wary that this is really crudely done but it works for now

 

 

 

#!/bin/sh

[ "$host" = "" ] && exit

# main
main()
{
  id=$startclan
  mkdir -p ../icons/$dir/
  echo "Started at `date +%T_%F`"
  while [ $id -le $lastclan ]; do
    update $id
    id=$((id+1))
  done
  optimize
  echo "Finished at `date +%T_%F`"
}

# update
# $1 - clanId
update()
{
  echo -n "$1 - "

  errors=0
  while [ 1 ]; do
    clanraw=$(wget -qO- "http://$host/clans/$id" |
		gawk -v IGNORECASE=1 -v RS='</title' 'RT{gsub(/.*<title[^>]*>/,"");print;exit}')
		
		IFS='['
		clan=( $clanraw )
		IFS=']'
		clan2=( ${clan[1]} )

#Clan removed or does not exist
    if [ "$clanraw" = " | World of Tanks and World of Warplanes Clans  " ]; then
      echo "REMOVED"
      return
#Error handling - server maintenance
    elif [ "$clan2" = "" ]; then
      errors=$((errors+1))
      if [ $errors -lt 2 ]; then
        echo -n "EMPTY `date +%T_%F` $errors.. "
        sleep 10m
        continue
      elif [ $errors -lt 6 ]; then
        echo -n "$errors.. "
        sleep 10m
        continue
      else
        echo "ERROR"
        return
      fi
    fi
    break
  done

  echo -n "[$clan2] => $clan2.png"
	mkdir -p $dir
	wget -q -O $dir/$clan2.png "http://$host/clans/media/clans/emblems/cl_${id:(-3)}/$id/emblem_64x64.png"
  echo " OK"
}

optimize()
{
  echo "Optimizing PNGs..."
  (
    cd ../icons/$dir
    pngoptimizer -file:*.png
  )
}

 

EDIT: also as of 2.3.2016 last clan created is ID:500072742 to end at this, simply edit update-eu.sh => lastclan:500072742

Edited by Okxa
  • Upvote 1

Share this post


Link to post

Short link
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...