-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch.py
More file actions
59 lines (56 loc) · 2.14 KB
/
Copy pathfetch.py
File metadata and controls
59 lines (56 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# -*- coding: utf-8 -*-
"""
pipya fetch file
Copyright (c) 2015 Brunston Poon
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Full license in LICENCE.txt
"""
import sys, os
import time
import json
import webbrowser
import feedparser
import helper as h
def main(uin):
wapi, user, citystr = h.kernfig()[0:3]
if "headlines" in uin:
if "npr" in uin:
h.rt(uin)
link = "http://www.npr.org/rss/rss.php?id=1001"
newsfeed = h.grab(link)
for i in range(10):
print("Item {0}: ".format(i+1) + h.bcolors.BOLD +\
newsfeed.entries[i].title +\
h.bcolors.ENDC)
print("Time Published ",newsfeed.entries[i].published)
elif "atlantic" in uin:
h.rt(uin)
link = "http://feeds.feedburner.com/TheAtlantic?format=xml"
newsfeed = h.grab(link)
for i in range(10):
print("Item {0}: ".format(i+1) + h.bcolors.BOLD +\
newsfeed.entries[i].title +\
h.bcolors.ENDC)
print("Time Published: ",newsfeed.entries[i].published)
else:
print(h.pipya() + "Defaulting to NPR!")
link = "http://www.npr.org/rss/rss.php?id=1001"
newsfeed = h.grab(link)
for i in range(10):
print("Item {0}: ".format(i+1) + h.bcolors.BOLD +\
newsfeed.entries[i].title +\
h.bcolors.ENDC)
print("Time Published ",newsfeed.entries[i].published)
h.cfgwriter("settings.cfg",2,link)
elif "weather" in uin:
currentcond = str('http://api.wunderground.com/api/'+wapi+\
'/geolookup/conditions/q/'+citystr+'.json')
parsed_json = h.wloader(currentcond)
h.wcurre(parsed_json)
currentforec = str('http://api.wunderground.com/api/'+wapi+\
'/geolookup/forecast/q/'+citystr+'.json')
parsed_json = h.wloader(currentforec)
h.wforec(parsed_json)
return None