Community Forums Today's Posts     Member List     Archive    
Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2012
    Posts
    4

    Question Retrieve Avatar through ClientQuery - Possible?

    Hi,

    Is it possible to retrieve the actual avatar image data via the ClientQuery plugin? I can see there is a clientvariable called client_flag_avatar, but cannot see how it is possible to retrieve the actual image data using that hash.

  2. #2
    Join Date
    Jan 2010
    Location
    Germany
    Posts
    2,039
    The Avatar displayed in the Client is directly loaded from a File already on your Harddisk. Not sure what client_flag_avatar actually contains right now, thought I'd be a boolean Flag whether that client does or does not have an avatar set, but if it looks like some sort of hash it's a pretty safe bet it's the filename of the avatar.

    Edit:
    Actually the Filename is derived from the UniqueID of the Client which you can definately get. See here
    Since you do know the Filename you just need the path which is derived from the Server UnqiueID in some fashion (can't remember which one anymore though). Then you can just load the File and do whatever you want to do.

    Edit2:
    Actually the Algorithm for the Folder Name is pretty simple and rather obvious - it's just the base64 encoded Server Unique ID.
    Last edited by SilentStorm; 02-06-2012 at 23:14. Reason: added algorithm for Folders... should've looked at the folder names before :/

  3. #3
    Join Date
    Jun 2012
    Posts
    4
    That's great, thanks. It gave me enough to get something working. I couldn't work out how to retrieve whatever is used to encode the server ID, so I just search all directories in the cache till I find the avatar file that matches.

    Here is my Python code in case it is of use to anyone else. If anyone has an insight into how to retrieve and decode the server unique ID I'd love to hear it

    Code:
    def find_avatar(client_unique_identifier):
        decoded = ""
        for c in base64.b64decode(client_unique_identifier):
            decoded += chr(((ord(c) & 0xf0) >> 4) + 97)
            decoded += chr((ord(c) & 0x0f) + 97)
    
        # This is the path on Linux, it is probably different on other platforms
        dir_path = os.path.expanduser("~/.ts3client/cache")
    
        for l in os.listdir(dir_path):
            p = os.path.join(dir_path, l, "clients", "avatar_%s" % decoded)
            if os.path.exists(p):
                return p
    Last edited by tanktarta; 02-06-2012 at 22:48.

  4. #4
    Join Date
    Jan 2010
    Location
    Germany
    Posts
    2,039
    Actually searching through all the Directories is kind of a bad idea. The Avatar Filename is always the same for each Unique ID, now if you had two different Avatars on two different Servers, your script would return whatever Folder comes first, which is not what you want. I realize this is (most likely) just a temporary workaround but still wanted to make you aware of this.

    Edit:
    Actually - LOL - the Folder Names are pretty damn obvious... just took a look at them again and it's just the base64 encoded ServerUniqueID.

    So the Full Path would be:
    "~/.ts3client/cache/" + base64_encode(server_unique_id) + "/clients/avatar_" + ts3_base16(base64_decode(client_unique_id))
    Last edited by SilentStorm; 02-06-2012 at 23:12.

  5. #5
    Join Date
    Jun 2012
    Posts
    4
    Quote Originally Posted by SilentStorm View Post
    Actually searching through all the Directories is kind of a bad idea. The Avatar Filename is always the same for each Unique ID, now if you had two different Avatars on two different Servers, your script would return whatever Folder comes first, which is not what you want. I realize this is (most likely) just a temporary workaround but still wanted to make you aware of this.
    Yeh, I'd rather not have done this Just wanted to something to work with.

    Actually - LOL - the Folder Names are pretty damn obvious... just took a look at them again and it's just the base64 encoded ServerUniqueID.
    Ah right, thanks. That's great, however, I cannot for the life of me work out how to get the this "ServerUniqueID" via any of the ClientQuery commands. The only ID field I can find is the servervariable virtualserver_id which has a value of 1.

    My cache directory has a name ZmJsdjhodGQySmgrckNjZFFpcUZiYjh0bjc0PQ==, which decodes to fblv8htd2Jh+rCcdQiqFbb8tn74=. I can't find this value anywhere.

    Any ideas? I must be missing something really simple here...

  6. #6
    Join Date
    Jan 2010
    Location
    Germany
    Posts
    2,039
    The closest thing to what you'd need is servervariables but according to the help it doesn't support retrieving the ServerUniqueID which is rather strange because the Client definately knows the Server UID.

    Edit: actually it's just an oversight in the help...
    Code:
    servervariable virtualserver_unique_identifier
    gives you exactly what you need.
    Last edited by SilentStorm; 03-06-2012 at 16:10.

  7. #7
    Join Date
    Jun 2012
    Posts
    4
    servervariable virtualserver_unique_identifier
    Perfect Thanks for taking the time to help me out.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [Resolved] ClientQuery Source Code
    By Wilson29thID in forum Plugins
    Replies: 3
    Last Post: 03-01-2012, 09:44
  2. [Official] ClientQuery Plugin
    By Peter in forum Plugins
    Replies: 7
    Last Post: 22-08-2011, 08:44
  3. ClientQuery: Getting my CLID
    By Triscopic in forum Plugins
    Replies: 6
    Last Post: 06-08-2011, 10:51
  4. ClientQuery plugin Source?
    By FaltyR in forum Plugins
    Replies: 1
    Last Post: 25-07-2011, 11:19
  5. ClientQuery plugin
    By florian_fr40 in forum Plugins
    Replies: 16
    Last Post: 14-10-2010, 17:33

Posting Permissions

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