summaryrefslogtreecommitdiff
path: root/plugin.video.spurs-tv/resources
diff options
context:
space:
mode:
authorMartijn Kaijser <mcm.kaijser@gmail.com>2016-02-28 20:02:47 +0100
committerMartijn Kaijser <mcm.kaijser@gmail.com>2016-02-28 20:02:47 +0100
commitebddc11cff6fa722b025f1ca228d05b0d47fa368 (patch)
tree4b8d87b8912b98cce9e5987f7d7ec9f5fb2fafac /plugin.video.spurs-tv/resources
parent990120b45b2ac3365ee5b855d8e3ddd18d2540ce (diff)
[plugin.video.spurs-tv] 2.7.0
Diffstat (limited to 'plugin.video.spurs-tv/resources')
-rw-r--r--plugin.video.spurs-tv/resources/__init__.py0
-rw-r--r--plugin.video.spurs-tv/resources/language/English/strings.xml19
-rw-r--r--plugin.video.spurs-tv/resources/lib/__init__.py0
-rw-r--r--plugin.video.spurs-tv/resources/lib/utils.py9
-rw-r--r--plugin.video.spurs-tv/resources/lib/youtube.py60
-rw-r--r--plugin.video.spurs-tv/resources/settings.xml12
6 files changed, 100 insertions, 0 deletions
diff --git a/plugin.video.spurs-tv/resources/__init__.py b/plugin.video.spurs-tv/resources/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/plugin.video.spurs-tv/resources/__init__.py
diff --git a/plugin.video.spurs-tv/resources/language/English/strings.xml b/plugin.video.spurs-tv/resources/language/English/strings.xml
new file mode 100644
index 0000000..f18052d
--- /dev/null
+++ b/plugin.video.spurs-tv/resources/language/English/strings.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<strings>
+ <string id="30000">Official Site</string>
+ <string id="30001">YouTube Channel</string>
+ <string id="30010">Latest</string>
+ <string id="30011">Search</string>
+ <string id="30012">Next Page</string>
+ <string id="30013">Previous Page</string>
+ <string id="30014">All</string>
+ <string id="30015">Popular</string>
+ <string id="30016">Playlists</string>
+
+ <string id="30100">Advanced</string>
+ <string id="30101">Debug</string>
+ <string id="30110">Official Site</string>
+ <string id="30111">Maximum video resolution</string>
+ <string id="30120">YouTube</string>
+ <string id="30121">Settings</string>
+</strings>
diff --git a/plugin.video.spurs-tv/resources/lib/__init__.py b/plugin.video.spurs-tv/resources/lib/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/plugin.video.spurs-tv/resources/lib/__init__.py
diff --git a/plugin.video.spurs-tv/resources/lib/utils.py b/plugin.video.spurs-tv/resources/lib/utils.py
new file mode 100644
index 0000000..9742a96
--- /dev/null
+++ b/plugin.video.spurs-tv/resources/lib/utils.py
@@ -0,0 +1,9 @@
+import time
+from datetime import date
+
+def date_from_str(date_str, date_format):
+ return date(*(time.strptime(date_str, date_format)[0:3]))
+
+def add_item_info(item, title, item_date):
+ item['info'] = {'title': title,
+ 'date': item_date.strftime("%d.%m.%Y")}
diff --git a/plugin.video.spurs-tv/resources/lib/youtube.py b/plugin.video.spurs-tv/resources/lib/youtube.py
new file mode 100644
index 0000000..2b222a6
--- /dev/null
+++ b/plugin.video.spurs-tv/resources/lib/youtube.py
@@ -0,0 +1,60 @@
+import os
+import json
+import requests
+from urlparse import urljoin, urlunparse
+
+import utils
+
+SCHEME = "https"
+HOST = "www.googleapis.com"
+PATH = "/youtube/v3/"
+
+CHANNEL_ID = "UCEg25rdRZXg32iwai6N6l0w"
+API_KEY = "AIzaSyAyfLT-xP3vrQLwejc22hYe5m0RoZXX2vA"
+
+QS_FMT = "part=snippet&key={0}&{{0}}Id={{1}}&maxResults={{2}}&q={{3}}&order={{4}}&type=video".format(API_KEY)
+
+
+def _get_items(resource, key="channel", id=CHANNEL_ID, max_results=50, order='date', query=""):
+ qs = QS_FMT.format(key, id, max_results, query, order)
+ url = urlunparse((SCHEME, HOST, os.path.join(PATH, resource), None, qs, None))
+ response = json.loads(requests.get(url).text)
+
+ for item in response['items']:
+ snippet = item['snippet']
+ thumbnail = snippet['thumbnails']['high']['url']
+ title = snippet['title']
+ published_at = utils.date_from_str(snippet['publishedAt'].split('T')[0], "%Y-%m-%d")
+
+ try:
+ id = item['id']['videoId'] # search result
+ except TypeError:
+ try:
+ id = snippet['resourceId']['videoId'] # playlist video
+ except KeyError:
+ id = item['id'] # playlist
+
+ yield id, title, thumbnail, published_at
+
+def get_playlists():
+ return _get_items("playlists")
+
+def get_playlist_items(playlist_id):
+ return _get_items("playlistItems", "playlist", playlist_id)
+
+def get_popular():
+ return _get_items("search", max_results=14, order="viewCount")
+
+def get_latest():
+ return _get_items("search", max_results=14)
+
+def get_search_results(query):
+ return _get_items("search", query=query)
+
+
+if __name__ == "__main__":
+ for playlist_id, title, thumbnail in get_playlists():
+ print
+ print title
+ for item_id, title, thumbnail in get_playlist_items(playlist_id):
+ print '\t', title
diff --git a/plugin.video.spurs-tv/resources/settings.xml b/plugin.video.spurs-tv/resources/settings.xml
new file mode 100644
index 0000000..ad12a6d
--- /dev/null
+++ b/plugin.video.spurs-tv/resources/settings.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<settings>
+ <category label="30110">
+ <setting label="30111" type="labelenum" id="resolution" values="272p|360p|576p|720p|1080p" default="1080p"/>
+ </category>
+ <category label="30120">
+ <setting label="30121" type="action" action="Addon.OpenSettings(plugin.video.youtube)" option="close"/>
+ </category>
+ <category label="30100">
+ <setting label="30101" type="bool" id="debug" default="false"/>
+ </category>
+</settings>