Browse Source

Initial code

Nikola Kotur 3 years ago
commit
7f3ff1c494
3 changed files with 48 additions and 0 deletions
  1. 16 0
      README.md
  2. 31 0
      fetch-favourites.py
  3. 1 0
      requirements.txt

+ 16 - 0
README.md

@@ -0,0 +1,16 @@
+# Fetch favourites from Pocket
+
+## Usage
+
+First, you have to [Create your consumer
+key](https://getpocket.com/developer/apps/new) from getpocket's developer
+console. To get the access token, you have to authorize the app on your own
+account. There are tools on the web that can automate this for you such as
+[fxneumann's
+OneClickPocket](http://reader.fxneumann.de/plugins/oneclickpocket/auth.php)
+
+Then run the tool and capture favourite URLs:
+
+```
+python fetch-favourites.py
+```

+ 31 - 0
fetch-favourites.py

@@ -0,0 +1,31 @@
+import os
+from pprint import pprint as pp
+
+from pocket import Pocket, PocketException
+
+
+if __name__ == '__main__':
+
+    p = Pocket(
+        consumer_key=os.environ.get('POCKET_CONSUMER_KEY', ''),
+        access_token=os.environ.get('POCKET_ACCESS_TOKEN', ''),
+
+    )
+
+    # Fetch a list of articles
+    try:
+        fetch_more = True
+        offset = 0
+        count = 10
+        while fetch_more:
+            items = p.retrieve(favorite=True, offset=offset, count=count)
+            try:
+                for item_id, item in items['list'].items():
+                    if not item['resolved_url']:
+                        continue
+                    print(item['resolved_url'])
+                offset += count
+            except AttributeError:
+                fetch_more = False
+    except PocketException as e:
+        print(e.message)

+ 1 - 0
requirements.txt

@@ -0,0 +1 @@
+pocket-api==0.1.5