GithubHelp home page GithubHelp logo

achembarpu / pockyt Goto Github PK

View Code? Open in Web Editor NEW
493.0 11.0 34.0 89 KB

Automate & manage your Pocket.com collection.

License: GNU General Public License v3.0

Python 100.00%
python command-line-tool getpocket

pockyt's Introduction

pockyt

A simple, yet powerful, commandline client for your Pocket collection.

image

image

About

Pocket is an application for managing a reading list of articles from the Internet.

pockyt is a commandline client that interfaces the pocket API and provides a way to interact with your Pocket collection. Using simple command sequences, routine tasks can be automated and reusable scripts can be created.

Privacy

pockyt does NOT track, store, or monitor your usage and/or data. Moreover, pockyt interacts with the pocket API using local credentials and does not attempt to communicate with any other services.

Installation

pockyt supports Python 2.7+ & 3.4+ on Windows, macOS, & GNU/Linux platforms.

  1. Install pockyt: pip install -U pockyt
  2. Connect Pocket account: pockyt reg
  3. Refer the Examples & Documentation below.

Examples

  • Get the latest 5 items' links & excerpts and save them to a file.

    pockyt get -n 5 -f '{link} - {excerpt}' -o readlater.txt
  • Get the oldest 10 items and delete them from Pocket.

    pockyt get -n 10 -r oldest -f '{id}' | pockyt mod -d -i redirect
  • Get all the items about 'python' and open them in a browser.

    pockyt get -q 'python' -o browser
  • Get all the links from a 'links.txt' and add them to Pocket.

    pockyt put -i links.txt
  • Get all favorited items and archive them.

    pockyt get -v 1 | pockyt mod -a 1 -i redirect
  • Get all favorited items and save offline copies of them.

    pockyt get -v 1 -a ./pocket

Contribute

Feel free to contribute features, bugfixes, improvements, and usage ideas.

  1. Fork pockyt.
  2. Work on the source code.

    git clone [email protected]:<username>/pockyt.git
    cd pockyt
    
    # runtime dependencies
    pip install -e .
    # devel dependencies
    pip install -r requirements.txt
    
    # do stuff
    git checkout -b new-feature
    
    # format files
    yapf -i -r .
    
    git add .
    git commit -am 'commit msg'
    git push origin new-feature
  3. Submit a pull request.

License

This project uses the GNU GPLv3 License.

Documentation

pockyt help/-h/--help :

help

show pockyt usage help

reg

connect a pocket account

get

get pocket collection, with useful item info

put

add to pocket collection, using links

mod

modify pocket collection, using item ids

pockyt reg -h :

-h, --help

show this help message and exit

--no-browser

use without browser i.e. print to console

pockyt get -h :

-h, --help

show this help message and exit

-c <type>, --content <type>

content type : <type> : {all, [article, video, image]}

-s <state>, --state <state>

collection state : <state> : {all, [unread, archive]}

-r <order>, --sort <order>

item sorting : <order> : {newest, [oldest, title, site]}

-n <amount>, --count <amount>

number of items : <amount> : {-1: all, [n: amount]}

-q <query>, --query <query>

search query : <query> : {None}

-t <option>, --tag <option>

filter tag : {-1: nofilter, [tagname: tagged, 0: untagged}

-v <option>, --favorite <option>

filter favorites : <option> : {-1: No Filter, [1: favorited, 0: un-favorited]}

-d <domain>, --domain <domain>

restrict items to domain : <domain> : {None}

-f <specifier>, --format <specifier>

format output : <specifier> : {'{id} | {title} | {link}', [id, title, link, excerpt, tags]}

-o <option>, --output <option>

redirect output : <option> : {None, [browser, filename]}

-a <path>, --archive <path>

save offline copies : <path> : path/to/archive/folder

--since <YYYY-MM-DD>

only return items modified since : <YYYY-MM-DD>

pockyt put -h :

-h, --help show this help message and exit -f <specifier>, --format <specifier> unformat input : <specifier> : {'{link}', [id, title, link, excerpt, tags]} -i <option>, --input <option> obtain input : <option> : {console, [redirect, link, filename]}

pockyt mod -h :

-h, --help show this help message and exit -f <specifier>, --format <specifier> unformat input : <specifier> : {'{id}', [id, title, link, excerpt, tags]} -i <option>, --input <option> obtain input : <option> : {console, [redirect, filename]} -d, --delete delete items -a <option>, --archive <option> archive items : <option> : {-1: None, [1: archive, 0: unarchive]} -v <option>, --favorite <option> favorite items : <option> : {-1: None, [1: favorite, 0: unfavorite]}

pockyt's People

Contributors

achembarpu avatar alphapapa avatar arvindch avatar asergi avatar luogni avatar shuichiro-makigaki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pockyt's Issues

how can I put title with url

I try to do this:

echo 'Usanov_Nauka-o-bogatstve.517832 http://ix.io/2fWf' | pockyt put -f '{title} {link}' -i redirect

nothing properly works

pockyt fails to install with Python 2.7

Attempting to pip install pockyt currently fails with:

running build
running build_py
Traceback (most recent call last):
  File "setup.py", line 53, in <module>
    'pockyt=pockyt.pockyt:main',
  File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/usr/lib/python2.7/distutils/command/build.py", line 127, in run
    self.run_command(cmd_name)
  File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/usr/lib/python2.7/site-packages/setuptools/command/build_py.py", line 51, in run
    self.build_packages()
  File "/usr/lib/python2.7/distutils/command/build_py.py", line 373, in build_packages
    self.build_module(module, module_file, package)
  File "/usr/lib/python2.7/site-packages/setuptools/command/build_py.py", line 71, in build_module
    package)
  File "/usr/lib/python2.7/distutils/command/build_py.py", line 334, in build_module
    "'package' must be a string (dot-separated), list, or tuple")
TypeError: 'package' must be a string (dot-separated), list, or tuple

In Python 2, unicode is not allowed for metadata fields as stated in the distutils documentation: None of the string values may be Unicode.

A possible solution would be to just remove unicode_literals from setup.py.
I'd rather suggest you to use setuptools.find_packages() to collect packages inside of your project directory:

diff --git a/setup.py b/setup.py
index 20ed8a8..d6702d5 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,7 @@
 from __future__ import absolute_import, print_function, unicode_literals, with_statement

 import sys
-from setuptools import setup
+from setuptools import setup, find_packages


 if sys.version_info[0:2] not in ((2, 7), (3, 4), (3, 5)):
@@ -21,7 +21,7 @@ except:

 setup(
     name=name,
-    packages=[name],
+    packages=find_packages(),
     version=version,
     description='automate and manage your pocket collection',
     long_description=desc,

If you agree, I'd like to open a PR.

Feature request: since flag for get requests

I'd love to be able to filter the articles by the date they were manipulated within Pocket. Some usage examples:

  • Get all the articles I've added since Monday.
  • Get all the articles I've archived this (or last) month.
  • Get all the articles I've favourited this year.

Something like:

pockyt get --since 2020-01-01 -s archived

Pocket API's get feature does have a since parameter, so it should definitely be possible.

pockyt reg hanging

This is with v1.4.2 in a python 3.6 virtualenv on ubuntu 18.04 aarch64.

Sits at "Note: During the registration process, pockyt will attempt to open the required links in your default browser. If any errors occur, you can use the printed links instead."

This is in the console, no X session.

Error on running pockyt reg

Hello!

I just heard about pockyt. I installed it via pipx install pockyt (my first use of pipx) and then ran pockyt reg. I got the following error:

---------------------------------------------------------------------
Bug Report :
`pockyt` has encountered an error! Please submit this bug report at
` https://www.github.com/achembarpu/pockyt/issues/new `.
---------------------------------------------------------------------
Python Version:
3.10.5 (main, Jul 31 2022, 08:19:00) [Clang 13.1.6 (clang-1316.0.21.2.5)]
---------------------------------------------------------------------
Installed Packages:
parse - 1.19.0
pockyt - 1.4.6
setuptools - 65.1.0
pip - 22.2.2
wheel - 0.37.1
---------------------------------------------------------------------
Commmand:
reg
---------------------------------------------------------------------
Error Message:
Traceback (most recent call last):
  File "/Users/jml/.local/pipx/venvs/pockyt/lib/python3.10/site-packages/pockyt/pockyt.py", line 227, in main
    error = app.run()
  File "/Users/jml/.local/pipx/venvs/pockyt/lib/python3.10/site-packages/pockyt/pockyt.py", line 214, in run
    auth.setup()
  File "/Users/jml/.local/pipx/venvs/pockyt/lib/python3.10/site-packages/pockyt/auth.py", line 97, in setup
    self._obtain_access_token()
  File "/Users/jml/.local/pipx/venvs/pockyt/lib/python3.10/site-packages/pockyt/auth.py", line 64, in _obtain_access_token
    response = Network.post_request(API.ACCESS_TOKEN_URL, payload)
  File "/Users/jml/.local/pipx/venvs/pockyt/lib/python3.10/site-packages/pockyt/wrapper.py", line 136, in post_request
    response = Response(urlopen(request))
  File "/Users/jml/.pyenv/versions/3.10.5/lib/python3.10/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "/Users/jml/.pyenv/versions/3.10.5/lib/python3.10/urllib/request.py", line 525, in open
    response = meth(req, response)
  File "/Users/jml/.pyenv/versions/3.10.5/lib/python3.10/urllib/request.py", line 634, in http_response
    response = self.parent.error(
  File "/Users/jml/.pyenv/versions/3.10.5/lib/python3.10/urllib/request.py", line 563, in error
    return self._call_chain(*args)
  File "/Users/jml/.pyenv/versions/3.10.5/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/Users/jml/.pyenv/versions/3.10.5/lib/python3.10/urllib/request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 500: Internal Server Error
---------------------------------------------------------------------

When creating the application, I entered "Pockyt" as the name, "Command-line client for Pocket" as the description, selected "Add", "Remove", and "Modify" as the permissions and "Mac" as the platform. Naturally I accepted the terms of service.

I then copy/pasted the consumer key into the terminal, and clicked "Authorize" in my browser. The browser redirected me to the Github repo and the command-line showed the error you see above.

I repeated all of the steps in case the 500 represents an intermittent server error. All of this took place at roughly 2022-08-19T06:00:00+00:00.

Thanks!

is it possible to get the entire article (as rendered by Pocket), not just the 'excerpt' ?

I know that for example,
to to get the latest 5 items' links & excerpts and save them to a file:
pockyt get -n 5 -f '{link} - {excerpt}' -o readlater.txt
works

Is is also possible to get the entire article, as it is displayed and rendered on the pocket website ?
I mean just the extracted text, stored on the Pocket.
I dont want to download from the original server and extract the text on my computer again.

Updating Pockyt for 3.8

similar issue to last year python 3.7 update, #13

This is just to check if pockyt, itself, is compatible with python 3.8, and it doesnt need python 2 at all.
It was working just fine until November 2019.
With ArchLinux update to python 3.8 this AUR package, https://aur.archlinux.org/packages/pockyt/

now breaks with:


This version of Python [3.8.0] is unsupported ! 
Please use Python 2.7.x, 3.4.x, 3.5.x, or 3.6.x !


Thanks for your work on this usefull tool. Keep using it after all these years !

Updating Pockyt for 3.7

Hey there,

after upgrading my python and seeing the error message, does anything prevent pockyt from running on 3.7? As far as I know, there have been breaking changes.

Many thanks!

Crash in `pockyt reg` with python2.7

Traceback (most recent call last):
  File "/Users/kergoth/.local/bin/pockyt", line 9, in <module>
    load_entry_point('pockyt==0.3', 'console_scripts', 'pockyt')()
  File "/Users/kergoth/.virtualenvs/pockyt/lib/python2.7/site-packages/pockyt/pockyt.py", line 147, in main
    app.run()
  File "/Users/kergoth/.virtualenvs/pockyt/lib/python2.7/site-packages/pockyt/pockyt.py", line 137, in run
    auth.run()
  File "/Users/kergoth/.virtualenvs/pockyt/lib/python2.7/site-packages/pockyt/auth.py", line 120, in run
    self._setup()
  File "/Users/kergoth/.virtualenvs/pockyt/lib/python2.7/site-packages/pockyt/auth.py", line 94, in _setup
    .format(API.AUTHORIZE_USER_URL(self._request_token)))
TypeError: unbound method <lambda>() must be called with API instance as first argument (got unicode instance instead)

Supported Python versions?

I can't tell which versions of Python this project supports. By the looks of it, I may need to be using Python 3.x.

This may also invalidate #1 depending on how config parsing works in 3.x.

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.