Skip to content

Commit

Permalink
Integration with Firebase and improved error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Fleker committed Oct 8, 2016
1 parent 91d9d6f commit f255644
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
/python/temp_apk
/python/*.log
/python/leanback_shortcuts
/python/to_generate.json
/python/leanbackshortcut.pyc
# Built application files

*.apk
Expand Down
28 changes: 23 additions & 5 deletions python/leanbackshortcut.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import shutil
import sys
import urllib
from firebase import firebase
# Get all of the new apks from firebase
# Run through them all
# Upload to server
Expand Down Expand Up @@ -129,8 +130,25 @@ def replace(file_path, pattern, subst):
shutil.move(abs_path, file_path)

# MAIN EXECUTION
if len(sys.argv) > 0 and (sys.argv[1] == '--debug' or sys.argv[1] == '-d'):
generate_apk("Cumulus TV", "com.felkertech.n.cumulustv", "https://github.com/Fleker/CumulusTV/blob/master/app/src/main/res/drawable-xhdpi/c_banner_3_2.jpg?raw=true")
else:
# Run through Firebase
print "Getting latest apps from Firebase"
if __name__ == '__main__':
if len(sys.argv) > 0 and (sys.argv[1] == '--debug' or sys.argv[1] == '-d'):
generate_apk("Cumulus TV", "com.felkertech.n.cumulustv", "https://github.com/Fleker/CumulusTV/blob/master/app/src/main/res/drawable-xhdpi/c_banner_3_2.jpg?raw=true")
elif len(sys.argv) > 0 and (sys.argv[1] == "--firebase"):
# Run through Firebase
print "Getting latest apps from Firebase"
firebase = firebase.FirebaseApplication('https://tv-app-repo.firebaseio.com', None)
result = firebase.get('/needShortcuts', None)
for app in result:
print "Generating " + result[app]['title']
print " * Package Name: " + app.replace('_', '.')
print " * Banner Url: " + result[app]['banner']
# Validate package name
if len(app.replace('_', '.').strip()) <= 0:
print "This app has no package name!"
break;
if len(result[app]['banner'].strip()) <= 0:
print "This app has no banner!"
break;
generate_apk(result[app]['title'], app.replace('_', '.'), result[app]['banner'])
else:
print "Unsupported action"
2 changes: 2 additions & 0 deletions python/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
requests==1.1.0
python-firebase

0 comments on commit f255644

Please sign in to comment.