├── LICENSE ├── README.md ├── add.sh ├── authenticate.sh └── open_in_browser.sh /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Richard Kraaijenhagen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Pocket-sh-add 2 | 3 | Add URLs to your pocket with a simple shell script, and some curl. No python 4 | installs, no dependencies, and no javascript! 5 | 6 | Integrates fantastically with any UNIX operating system, seemlessly connects to 7 | lynx, mutt, newsbeuter, newsboat! 8 | 9 | 10 | ## Installation 11 | 12 | #### Authenticate the user 13 | This will propegate a config file in ~/.pocketshrc with your token. Activate 14 | the link opened in your browser and hit enter. 15 | ``` 16 | ./authenticate.sh 17 | ``` 18 | 19 | #### Add a URL 20 | Add any URL with the add.sh script. 21 | ``` 22 | ./add.sh https://github.com/riichard/pocket-sh-add/blob/master/README.md 23 | 24 | ``` 25 | 26 | #### Add a URL with tags 27 | ``` 28 | ./add.sh https://slate.com/human-interest/2019/11/50-best-nonfiction-books.html "books, nonfiction" 29 | ``` 30 | -------------------------------------------------------------------------------- /add.sh: -------------------------------------------------------------------------------- 1 | source ~/.pocketshrc 2 | 3 | curl -sS -X POST \ 4 | -F "url=$1" \ 5 | -F "tags=$2" \ 6 | -F "consumer_key=$CONSUMER_KEY" \ 7 | -F "access_token=$ACCESS_TOKEN" \ 8 | https://getpocket.com/v3/add 9 | -------------------------------------------------------------------------------- /authenticate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | CONSUMER_KEY="83822-4b63bd22bd3b9252d894d734" 4 | 5 | CODE=$(curl -sS -X POST -d "consumer_key=$CONSUMER_KEY&redirect_uri=http://localhost/" https://getpocket.com/v3/oauth/request | awk -F'[=&]' '{print $2}') 6 | 7 | ./open_in_browser.sh "https://getpocket.com/auth/authorize?request_token=$CODE&redirect_uri=http://localhost/" 8 | 9 | read -p "Press enter when token is activated:" 10 | 11 | ACCESS_TOKEN=$(curl -S -X POST \ 12 | -d "consumer_key=$CONSUMER_KEY&code=$CODE" \ 13 | https://getpocket.com/v3/oauth/authorize | awk -F'[=&]' '{print $2}') 14 | 15 | cat >~/.pocketshrc </dev/null 2>&1 ; then 8 | viewer="$possibility" 9 | break 10 | fi 11 | done 12 | if [ "$viewer" = FAIL ] ; then 13 | echo 'No viewer found.' >&2 14 | exit 1 15 | fi 16 | 17 | # Now $viewer is set, so we can use it. 18 | "$viewer" "$1" 19 | --------------------------------------------------------------------------------