photomgr

package module
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2024 License: MIT Imports: 14 Imported by: 3

README

photomgr: A photo crawler manager for gomobile usage in Golang

GitHub license GoDocGo

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

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.

Bitdeli Badge

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckTitleWithBeauty added in v0.3.4

func CheckTitleWithBeauty(title string) bool

CheckTitleWithBeauty: check if title contains "美女" or "美女圖" or "美女圖片" or "美女圖片"

Types

type CK101

type CK101 struct {

	//To store current CK101 post result
	BaseDir string
	// contains filtered or unexported fields
}

func NewCK101

func NewCK101() *CK101

func (*CK101) Crawler

func (p *CK101) Crawler(target string, workerNum int)

func (*CK101) GetAllImageAddress added in v0.3.3

func (p *CK101) GetAllImageAddress(target string) []string

GetAllImageAddress: return all image address in current page.

func (*CK101) GetCurrentPageResultCount

func (b *CK101) GetCurrentPageResultCount() int

Return parse page result count, it will be 0 if you still not parse any page

func (*CK101) GetPostStarByIndex

func (b *CK101) GetPostStarByIndex(postIndex int) int

Get post like count by index in current parsed page

func (*CK101) GetPostTitleByIndex

func (b *CK101) GetPostTitleByIndex(postIndex int) string

Get post title by index in current parsed page

func (*CK101) GetPostUrlByIndex

func (b *CK101) GetPostUrlByIndex(postIndex int) string

Get post URL by index in current parsed page

func (*CK101) HasValidURL

func (b *CK101) HasValidURL(url string) bool

func (*CK101) ParseCK101PageByIndex

func (p *CK101) ParseCK101PageByIndex(page int) int

Set CK101 board page index, fetch all post and return article count back

type FBAlbum

type FBAlbum struct {

	//To store current FBAlbum post result
	BaseDir string
	// contains filtered or unexported fields
}

func NewFBAlbum

func NewFBAlbum() *FBAlbum

func (*FBAlbum) Crawler

func (p *FBAlbum) Crawler(target string, workerNum int)

func (*FBAlbum) GetAllImageAddress added in v0.3.3

func (p *FBAlbum) GetAllImageAddress(target string) []string

GetAllImageAddress: return all image address in current page.

func (*FBAlbum) GetCurrentPageResultCount

func (b *FBAlbum) GetCurrentPageResultCount() int

Return parse page result count, it will be 0 if you still not parse any page

func (*FBAlbum) GetPostStarByIndex

func (b *FBAlbum) GetPostStarByIndex(postIndex int) int

Get post like count by index in current parsed page

func (*FBAlbum) GetPostTitleByIndex

func (b *FBAlbum) GetPostTitleByIndex(postIndex int) string

Get post title by index in current parsed page

func (*FBAlbum) GetPostUrlByIndex

func (b *FBAlbum) GetPostUrlByIndex(postIndex int) string

Get post URL by index in current parsed page

func (*FBAlbum) HasValidURL

func (b *FBAlbum) HasValidURL(url string) bool

func (*FBAlbum) ParseFBAlbumPageByIndex

func (p *FBAlbum) ParseFBAlbumPageByIndex(page int) int

Set FBAlbum board page index, fetch all post and return article count back

type PTT

type PTT struct {

	//Handle base folder address to store images
	BaseDir       string
	SearchAddress string
	// contains filtered or unexported fields
}

func NewPTT

func NewPTT() *PTT

func (*PTT) Crawler

func (p *PTT) Crawler(target string, workerNum int)

Crawler: parse ptt board page by index

func (*PTT) GetAllFromURL added in v0.6.0

func (p *PTT) GetAllFromURL(url string) (title string, allImages []string, like, dis int)

GetAllFromURL: return all post images, like and dis in current page

func (*PTT) GetAllImageAddress added in v0.3.3

func (p *PTT) GetAllImageAddress(target string) []string

GetAllImageAddress: return all image address in current page.

func (*PTT) GetCurrentPageResultCount

func (p *PTT) GetCurrentPageResultCount() int

Return parse page result count, it will be 0 if you still not parse any page

func (*PTT) GetPostLikeDis added in v0.3.4

func (p *PTT) GetPostLikeDis(target string) (int, int)

func (*PTT) GetPostStarByIndex

func (p *PTT) GetPostStarByIndex(postIndex int) int

Get post like count by index in current parsed page

func (*PTT) GetPostTitleByIndex

func (p *PTT) GetPostTitleByIndex(postIndex int) string

Get post title by index in current parsed page

func (*PTT) GetPostUrlByIndex

func (p *PTT) GetPostUrlByIndex(postIndex int) string

Get post URL by index in current parsed page

func (*PTT) GetUrlTitle added in v0.5.0

func (p *PTT) GetUrlTitle(target string) string

GetUrlTitle: return title and url of post

func (*PTT) HasValidURL

func (b *PTT) HasValidURL(url string) bool

func (*PTT) ParsePttByNumber added in v0.3.6

func (p *PTT) ParsePttByNumber(num int, page int) int

Set Ptt board psot number, fetch assigned (at least) number of posts. Return real number.

func (*PTT) ParsePttPageByIndex

func (p *PTT) ParsePttPageByIndex(page int, replace bool) int

Set Ptt board page index, fetch all post and return article count back

func (*PTT) ParseSearchByKeyword added in v0.7.0

func (p *PTT) ParseSearchByKeyword(keyword string) int

Search with specific keyword, fetch all post and return article count back

type PostDoc added in v0.3.5

type PostDoc struct {
	ArticleID    string   `json:"article_id" bson:"article_id"`
	ArticleTitle string   `json:"article_title" bson:"article_title"`
	Author       string   `json:"author" bson:"author"`
	Date         string   `json:"date" bson:"date"`
	URL          string   `json:"url" bson:"url"`
	ImageLinks   []string `json:"image_links" bson:"image_links"`
	Likeint      int      `json:"likeint" bson:"likeint"`
	Dislikeint   int      `json:"dislikeint" bson:"dislikeint"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL