forked from jackychi/FindYYeTs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfindyyets_api.py
More file actions
29 lines (21 loc) · 813 Bytes
/
findyyets_api.py
File metadata and controls
29 lines (21 loc) · 813 Bytes
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
# -*- coding: utf-8 -*-
__author__ = 'Sagacity'
import urllib2
import json
theQuery = "{query}"
theQuery = theQuery.strip()
apiurl = 'http://www.yyets.com/php/search/api?keyword='
urldoc = json.loads( urllib2.urlopen( apiurl + theQuery ).read())
results = urldoc["data"]
if not results:
exit()
print "<?xml version=\"1.0\"?>\n<items>"
for res in results:
link = "http://www.yyets.com/" + res["type"] + "/" + res["itemid"]
title = res["title"].replace( "&", "#" )
print " <item uid=\"YYeTs\" arg=\""+ link +"\">"
print " <title>" + title.encode('utf-8') + "</title>"
print " <subtitle>" + (res["prefix"] + title).encode('utf-8') + "</subtitle>"
print ''' <icon type="fileicon">/Applications/QuickTime Player.app/</icon>
</item>'''
print "</items>\n"