Skip to content

Commit

Permalink
Updated API keys for external services, allow API key override (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
jez500 committed Jul 27, 2018
1 parent ef6998f commit 50e59e7
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/js/app.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
showDeviceName: false
refreshIgnoreNFO: true
largeBreakpoint: 910
apiKeyTMDB: ''
apiKeyTVDB: ''
apiKeyFanartTv: ''
apiKeyYouTube: ''
}

## The App Instance
Expand Down
9 changes: 9 additions & 0 deletions src/js/apps/settings/show/local/local_controller.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@
{id: 'refreshIgnoreNFO', title: tr("Refresh Ignore NFO"), type: 'checkbox', defaultValue: true, description: tr('Ignore local NFO files when manually refreshing media.')}
]
}
{
title: 'API Keys'
id: 'apikeys'
children:[
{id: 'apiKeyTMDB', title: tr("The Movie DB"), type: 'textfield', defaultValue: '', description: tr("Set your own TMDB API key.")}
{id: 'apiKeyFanartTv', title: tr("FanartTV"), type: 'textfield', defaultValue: '', description: tr("Set your own FanartTv API key.")}
{id: 'apiKeyYouTube', title: tr("YouTube"), type: 'textfield', defaultValue: '', description: tr("Set your own YouTube API key.")}
]
}
]

## Get settings from local storage
Expand Down
4 changes: 2 additions & 2 deletions src/js/entities/external/fanarttv.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
API =

# Using the Kodi API key
apiKey: 'ed4b784f97227358b31ca4dd966a04f1'
apiKey: 'ZWQ0Yjc4NGY5NzIyNzM1OGIzMWNhNGRkOTY2YTA0ZjE='

# V3 of API
baseURL: 'http://webservice.fanart.tv/v3/'
Expand All @@ -18,7 +18,7 @@
## Make a call to API
call: (path, params, callback) ->
defaultParams =
api_key: @apiKey
api_key: config.getAPIKey('apiKeyFanartTv', @apiKey)
params = _.extend defaultParams, params
url = @baseURL + path + helpers.url.buildParams(params)
req = $.getJSON url, (resp) ->
Expand Down
6 changes: 3 additions & 3 deletions src/js/entities/external/themoviedb.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

API =

# Using the Kodi API key
apiKey: 'ecbc86c92da237cb9faff6d3ddc4be6d'
# API Key
apiKey: 'NzFiYTFmMDdlZDBmYzhmYjM2MWNmMDRhNThkNzUwNTE='

# V3 of API
baseURL: 'https://api.themoviedb.org/3/'
Expand All @@ -29,7 +29,7 @@
## Make a call to API
call: (path, params, callback) ->
defaultParams =
api_key: @apiKey
api_key: config.getAPIKey('apiKeyTMDB', @apiKey)
params = _.extend defaultParams, params
url = @baseURL + path + helpers.url.buildParams(params) + '&callback=?'
$.getJSON url, (resp) ->
Expand Down
4 changes: 2 additions & 2 deletions src/js/entities/external/youtube.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

API =

apiKey: 'AIzaSyBxvaR6mCnUWN8cv2TiPRmuEh0FykBTAH0'
apiKey: 'QUl6YVN5Qnh2YVI2bUNuVVdOOGN2MlRpUFJtdUVoMEZ5a0JUQUgw'
searchUrl: 'https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&videoDefinition=any&videoEmbeddable=true&order=relevance&safeSearch=none'
maxResults: 5

kodiUrl: 'plugin://plugin.video.youtube/?action=play_video&videoid='
ytURL: 'https://youtu.be/'

getSearchUrl: ->
@searchUrl + '&key=' + @apiKey
@searchUrl + '&key=' + config.getAPIKey('apiKeyYouTube', @apiKey)

parseItems: (response) ->
items = []
Expand Down
5 changes: 5 additions & 0 deletions src/js/helpers/config.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ config.setLocal = (id, data, callback) ->
config.setLocalApp = () ->
config.set 'static', id, data, callback

# A wrapper for getting an API Key.
config.getAPIKey = (id, defaultData = '') ->
key = config.getLocal id, ''
return if key is '' then atob(defaultData) else key

# Wrapper for getting a config value before app has started.
# Should always try and use config.get() before this.
config.preStartGet = (id, defaultData = '') ->
Expand Down

0 comments on commit 50e59e7

Please sign in to comment.