Giter Club home page Giter Club logo

simplecache's Introduction

simplecache

C/C++ CI

Chrome(Linux) cache extractor.

Usage

[usage]
simplecache [OPTIONS]
--list  -l      list all keys
--cache -c      cache directory
--key   -k      key
--out   -o      output path

Get list of cache

simplecache --cache ~/.cache/google-chrome/Default/Cache/ --list

Save cached file

simplecache --cache ~/.cache/google-chrome/Default/Cache/ --key https://example.com/image.png --out myimage.png

Python Binding

pip install chromesimplecache
from simplecache import SimpleCacheEntry
import glob
import urllib.parse
import os
import brotli
import gzip
import zlib

cache_dir = os.path.expanduser('~/.cache/google-chrome/Default/Cache/*_0')
out_dir = 'cache'

if not os.path.exists(out_dir):
    os.mkdir(out_dir)

for entry_file in glob.glob(cache_dir):
    e = SimpleCacheEntry(entry_file)
    url = e.get_key()
    print(url)

    filename = urllib.parse.quote(url, safe='')[:255]
    encoding = e.get_header().headers.get('content-encoding', '').strip().lower()
    out_path = os.path.join(out_dir, filename)

    if encoding:
        # decompress with python
        data = e.get_data()
        if encoding == 'gzip':
            data = gzip.decompress(data)
        elif encoding == 'br':
            data = brotli.decompress(data)
        elif encoding == 'deflate':
            data = zlib.decompress(data)

        with open(out_path, 'wb') as f:
            f.write(data)
    else:
        # faster for binary
        e.save(out_path)

Install

Download artifacts from here or manually build.

Build

Build on host

sudo apt-get install -y g++ python3.8-dev make python3-pip
pip3 install pybind11
make

Build with docker

sudo docker-compose up --build
  • Specify python version in docker-compose.yml (default python3.8)

simplecache's People

Contributors

3437 avatar shosatojp avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.