User Tools

Site Tools


codesnip:unread_leed

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
codesnip:unread_leed [2014/02/02 11:36] – [Code] redoxcodesnip:unread_leed [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1
Line 1: Line 1:
-# LeedUnread 
- 
-## Overview 
- 
-It's a small Python3 script that retrieve the total of unread RSS feed from your Leed RSS Reader. The plugin LeedApi needs to be installed for this script to work 
- 
-You need to provide: 
- 
-* The URL fo your server 
-* Your username, in plain text 
-* The salted password that's stored in the `users` table 
-  * It seems to be the only way to use the API... Not really easy though >_< 
- 
-## Code 
-<code python LeedUnread.py> 
-#!/usr/bin/env python 
-# -*- coding: utf-8 -*- 
- 
-# Python modules 
-import requests # API Calls 
-import json # Parse API data 
-import hashlib # MD5 
- 
-_ServURL = 'http://YOUR_SERVER/plugins/api/' 
-_Login = 'YOUR_LOGIN' 
-_Pwd = 'YOUR_SALTED_PASSWORD' 
- 
-def APICall(cmd): 
- sess = requests.Session() 
- url = _ServURL + 'login.php?login='+_Login+'&password='+_Pwd 
- payload = { } 
- headers = {'content-type': 'application/x-www-form-urlencoded'} 
- r = sess.get(url, data=json.dumps(payload), headers=headers, auth=requests.auth.HTTPDigestAuth(_Login, _Pwd)) 
-  
- url = _ServURL + 'json.php?option='+cmd 
- payload = { } 
- headers = {'content-type': 'application/x-www-form-urlencoded'} 
- r = sess.post(url, data=json.dumps(payload), headers=headers) 
- rj = json.loads(r.text) 
- return rj 
- 
-# Pretty dump of a JSON object 
-def jDump(obj): 
- print(json.dumps(obj,indent=2)) 
- 
-Nb = 0; 
-rj = APICall('getFolders&unreadOnly') 
-#jDump(rj) 
-if 'folders' in rj: 
- folders = rj['folders'] 
- for folder in folders: 
- if 'flux' in folder: 
- #if 'titre' in folder: 
- # print(folder['titre']) 
- for flux in folder['flux']: 
- flux = folder['flux'][flux] 
- if 'nbNoRead' in flux: 
- #if 'name' in flux: 
- #print(flux['name'],'-',flux['nbNoRead']) 
- Nb = Nb + int(flux['nbNoRead']); 
-print(Nb) 
-</code> 
  
/home/share/www/redox.ws/wiki/data/attic/codesnip/unread_leed.1391340987.txt.gz · Last modified: 2023/11/24 21:55 (external edit)