photomgr: A photo crawler manager for gomobile usage in Golang
May 26, 2025 Ā· View on GitHub
A photomgr is a Go package to browse some info (such as PTT/CK101.. more) and download image if any default image in that article. This tool help you to download those photos for your backup, all the photos still own by original creator.
Install
go get github.com/kkdai/photomgr
Configuration
PTT Functionality (Firecrawl API)
To use the PTT scraping features (e.g., ptt_cli), you need a Firecrawl API key.
Firecrawl is used to fetch and parse PTT pages. You can obtain an API key from https://www.firecrawl.dev/.
Set the API key as an environment variable named FIRECRAWL_KEY:
For Linux/macOS:
export FIRECRAWL_KEY="YOUR_FIRECRAWL_API_KEY"
For Windows (Command Prompt):
set FIRECRAWL_KEY=YOUR_FIRECRAWL_API_KEY
Alternatively, you can place it in a .env file in the project root if your environment supports it (this project does not automatically load .env files, so you'd need a mechanism like godotenv or run it as source .env && ./your_app):
FIRECRAWL_KEY="YOUR_FIRECRAWL_API_KEY"
Ensure this variable is set before running any PTT-related commands.
Usage
refer cmd/ptt_cli or cmd/ck101_cli for more detail.
ptt := NewPTT()
//Set path for download image
ptt.BaseDir = "YOURPATH"
pageIndex := 0
totalPostCount := ptt.ParsePttPageByIndex(pageIndex)
//iterator this sample
for i := 0; i < totalPostCount ; i_++ {
title := p.GetPostTitleByIndex(i)
likeCount := p.GetPostStarByIndex(i)
fmt.Printf("%d:[%dā
]%s\n", i, likeCount, title)
//download image
url := p.GetPostUrlByIndex(i)
p.Crawler(url, 25)
}
If you want to run it directly, just run
PTT CLI
go install github.com/kkdai/photomgr/cmd/ptt_cli
CK101 CLI
go install github.com/kkdai/photomgr/cmd/ck101_cli
Refer iloveptt for detail commands.
Gomobile supported
To let your package support gomobile, need note as follow:
- Only support
string,int(no slice and array) - Need a constructor for your structure such as
NewYOUROBJ() *YOUROBJ.
How to build this package in iOS using Gomobile
Here is howto to teach you how to use this in iOS.
//Get gomobile and init it
//It might take some time
go get golang.org/x/mobile/cmd/gomobile
gomobile init
//Get this package and build package for iOS
go get github.com/kkdai/photomgr
gomobile bind -target=ios github.com/kkdai/photomgr
//It will generate a photomgr.framework in your cd $GOPATH/src/github.com/kkdai/photomgr
//Drag photomgr.framework in your xcode project
for more detail, check my iOS project PhotoViewer
TODO
- PTT
- gomobile refine
- download image
- CK101
- broad travaeral
- download image
- Timliao
- broad travaeral
- download image
- Gigacircle
- broad travaeral
- download image
Contribute
Please open up an issue on GitHub before you put a lot efforts on pull request.
The code submitting to PR must be filtered with gofmt
Project52
It is one of my project 52.
License
This package is licensed under MIT license. See LICENSE for details.
