ByMykel / CSGO-API

An unofficial JSON API for Counter-Strike 2 in multiples languages. List of skins, cases, stickers, collections, collectibles, agents, graffiti, keys, patches and music kits.
https://bymykel.github.io/CSGO-API/
MIT License
260 stars 31 forks source link

How does the api get the CDN images? #25

Closed wavpro closed 1 year ago

wavpro commented 1 year ago

I noticed that it doesn't look like the automatic update script gets them, do you do it manually, and if so where do you find the images?

ByMykel commented 1 year ago

@wavpro

Most of the graphical resources for CSGO are stored in VPK files which include the sticker, music kit, tools, and status icon images. The root of a VPK contains a dir file (pak01_dir.vpk) that specifies where files are located over multiple packages. If you look in the install directory of CS:GO, you'll see pak01_003.vpk, pak01_004.vpk, etc... where these files are located.

Text extracted from node-csgo-cdn

I'am using VRF to decompile VPK packages and extract all the images.

You have to download de CLI Decompiler and run the command below changing the path to where is your pak01_dir.vpk located and the output path.

C:\Users\ByMykel\Desktop\Decompiler-windows-x64\Decompiler.exe --input "D:\Steam\steamapps\common\Counter-Strike Global Offensive\csgo\pak01_dir.vpk" --output D:\csgo_images -e "png"

To get the cdn name you have to hash the file with SHA1 and generate the URL for that item.

For example this image is located in D:\csgo_images\resource\flash\econ\stickers\paris2023\apex.png. apex When I hash the file I get 7474f5912af1e1a42197390348a0d5c5f2cae3c7.

BASE URL -> https://steamcdn-a.akamaihd.net/apps/730/icons/

Add hash value to the end /{NAME}.{HASH}.png

/econ/stickers/paris2023/apex.png
/econ/stickers/paris2023/apex.7474f5912af1e1a42197390348a0d5c5f2cae3c7.png

Result: https://steamcdn-a.akamaihd.net/apps/730/icons/econ/stickers/paris2023/apex.7474f5912af1e1a42197390348a0d5c5f2cae3c7.png

BTW you can fetch the cdn links from https://bymykel.github.io/CSGO-API/api/cdn_images.json

wavpro commented 1 year ago

Thank you a lot!

wavpro commented 1 year ago

Hey, sorry if I'm asking too much, but do you know how colored graffitis work? The game files seem to only contain the default ones without color, and not the actual ones you find in game. I'd assume there is some kind of overlay or something that is applied to the graffitis, but it could also be something in the game's code. I'd appreciate any clues you might have to how they work.

ByMykel commented 1 year ago

@wavpro

You can ask whatever you want, I'm happy yo help.

I have no clue how colored graffitis work, but if you notice in the images files some skins have multiple images and other just one.

So it could be that they are or were in the game files, but we can't see them? Really I don't know and these are just assumptions.

wavpro commented 1 year ago

Thank you again. Sadly I don't think it's how it works. I'll probably end up just scraping the market for the images, though that does suck as a solution.

ByMykel commented 1 year ago

@wavpro Try to ask in this forum https://dev.doctormckay.com/forum/10-general/