pocketcleaner

package module
v0.0.0-...-5ad54ce Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2016 License: MIT Imports: 9 Imported by: 0

README

pocketcleaner

Build Status Coverage Status Code Climate Packagecloud GoDoc MIT license

Overview

This is a utility to keep your Pocket list small and manageable. It will archive all items in your list except for the newest n items.

WARNING: This will archive items. Something you can't just undo.

Usage

pocketcleaner keeps your pocket clean

Usage:
  pocketcleaner [-d | --debug] [--keep=<keepCount>]
  pocketcleaner -h | --help | -v | --version

Options:
  -h --help          Show this screen.
  -d --debug         Show debug information.
  -v --version       Show version.
  --config=<config>  Config file to use
  --keep=<keepCount> Count of items to keep

Installation

Get auth tokens to use with pocketcleaner

Pocketcleaner doesn't come with any auth keys, so you will have to get your own. The following steps are taken from here.

1. Create an app in the developer portal

Make sure it has at least the retrieve and modify permissions.

2. Get a request token
curl https://getpocket.com/v3/oauth/request -X POST \
-H "Content-Type: application/json" -H "X-Accept: application/json" \
-d '{"consumer_key":"your-key-here","redirect_uri":"http://www.google.com"}'
3. Authorize the app

Visit the following URL in your browser and authorize the app.

https://getpocket.com/auth/authorize?request_token=request-token-here&redirect_uri=http://www.google.com
4. Convert request token to access token
curl https://getpocket.com/v3/oauth/authorize -X POST \
-H "Content-Type: application/json" -H "X-Accept: application/json" \
-d '{"consumer_key":"your-key-here","code":"request-token"}'
5. Make sure the token works by getting a list of your saved items
curl http://getpocket.com/v3/get -X POST -H "Content-Type: application/json" \
-H "X-Accept: application/json" \
-d '{"consumer_key":"your-key-here", "access_token":"access-token"}'
Install pocketcleaner

There are packages for linux up on packagecloud.io but you can also just clone the repo and build the binary yourself.

go get github.com/mrtazz/pocketcleaner
cd $GOPATH/src/github.com/mrtazz/pocketcleaner
make
Docker

There is also a docker image on docker hub which you can use to run pocketcleaner like this:

docker pull mrtazz/pocketcleaner
docker run -i -e "POCKETCLEANER_CONSUMER_SECRET=your_secret" -e "POCKETCLEANER_ACCESS_TOKEN=your_token" --rm mrtazz/pocketcleaner

Configuration

pocketcleaner reads the configuration file $HOME/.pocketcleaner.ini to get consumer key, access token, and the number of items to keep. The format looks like this:

consumer_key      = consumer-key
access_token      = access-token
keep_count        = 100

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Debug can be set to true to get debug logging from pocketcleaner
	Debug = false
)

Functions

This section is empty.

Types

type PocketClient

type PocketClient struct {
	BaseURL        string
	ConsumerSecret string
	APIToken       string
	HTTPClient     *http.Client
	KeepCount      int
}

PocketClient struct to interact with the API. This mostly holds the API token and secret, but also provides a way to mock out the HTTP client library so the code is easier to test.

func PocketClientWithToken

func PocketClientWithToken(apiToken string, consumerSecret string, toKeep int) *PocketClient

PocketClientWithToken returns a PocketClient with the provided token and consumer secret set as well as the provided number of articles to keep.

func (*PocketClient) CleanUpItems

func (c *PocketClient) CleanUpItems() (archived int, err error)

CleanUpItems is the main method to use this module from. After configuring the client with access token and consumer secret and the number of items to keep, just run this method and it will clean up your pocket account.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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