Skip to content

Commit

Permalink
Merge pull request #513 from Fish2/Icon
Browse files Browse the repository at this point in the history
Add Intercept Apple TV Icon with config
  • Loading branch information
moodyblue authored Feb 24, 2018
2 parents b9545b2 + ce1ff1c commit c737d8a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 8 deletions.
10 changes: 7 additions & 3 deletions DNSServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,13 @@ def Run(cmdPipe, param):

intercept = [param['HostToIntercept']]
restrain = []
if param['CSettings'].getSetting('intercept_atv_icon')=='True':
intercept.append('a1.phobos.apple.com')
dprint(__name__, 0, "Intercept Atv Icon: Enabled")
if param['CSettings'].getSetting('prevent_atv_update')=='True':
restrain = ['mesu.apple.com', 'appldnld.apple.com', 'appldnld.apple.com.edgesuite.net']

dprint(__name__, 0, "Prevent Atv Update: Enabled")

dprint(__name__, 0, "***")
dprint(__name__, 0, "DNSServer: Serving DNS on {0} port {1}.", cfg_IP_self, cfg_Port_DNSServer)
dprint(__name__, 1, "intercept: {0} => {1}", intercept, cfg_IP_self)
Expand Down Expand Up @@ -442,6 +446,6 @@ def Run(cmdPipe, param):

param['IP_self'] = '192.168.178.20' # IP_self?
param['baseURL'] = 'http://'+ param['IP_self'] +':'+ cfg.getSetting('port_webserver')
param['HostToIntercept'] = 'trailers.apple.com'
param['HostToIntercept'] = cfg.getSetting('hosttointercept')

Run(cmdPipe[1], param)
3 changes: 3 additions & 0 deletions Settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
Intercept: Trailers-trailers.apple.com, WSJ-secure.marketwatch.com, iMovie-www.icloud.com
HTTP: port_webserver - override when using webserver + forwarding to PlexConnect
HTTPS: port_ssl, certfile, enable_webserver_ssl - configure SSL portion or webserver
intercept_atv_icon: changes atv icon to plex icon
"""
g_settings = [
('enable_plexgdm' , ('True', '((True)|(False))')),
Expand All @@ -29,6 +30,8 @@
('port_dnsserver' , ('53', '[0-9]{1,5}')),
('ip_dnsmaster' , ('8.8.8.8', '([0-9]{1,3}\.){3}[0-9]{1,3}')),
('prevent_atv_update' , ('True', '((True)|(False))')),
('intercept_atv_icon' , ('True', '((True)|(False))')),
('icon', ('movie-trailers', '[a-zA-Z0-9_.-]+')),
\
('enable_plexconnect_autodetect', ('True', '((True)|(False))')),
('ip_plexconnect' , ('0.0.0.0', '([0-9]{1,3}\.){3}[0-9]{1,3}')),
Expand Down
21 changes: 18 additions & 3 deletions WebServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,22 @@ def do_GET(self):
JS = JSConverter(basename, options)
self.sendResponse(JS, 'text/javascript', True)
return


# proxy phobos.apple.com to support PlexConnect main icon
if "a1.phobos.apple.com" in self.headers['Host']:
resource = self.headers['Host']+self.path
icon = g_param['CSettings'].getSetting('icon')
if basename.startswith(icon):
icon_res = basename[len(icon):] # cut string from settings, keeps @720.png/@1080.png
resource = sys.path[0] + '/assets/icons/icon'+icon_res
dprint(__name__, 1, "serving "+self.headers['Host']+self.path+" with "+resource)
r = open(resource, "rb")
else:
r = urllib.urlopen('http://'+resource)
self.sendResponse(r.read(), 'image/png', False)
r.close()
return

# serve "*.jpg" - thumbnails for old-style mainpage
if self.path.endswith(".jpg"):
dprint(__name__, 1, "serving *.jpg: "+self.path)
Expand Down Expand Up @@ -376,8 +391,8 @@ def Run_SSL(cmdPipe, param):

param['IP_self'] = '192.168.178.20' # IP_self?
param['baseURL'] = 'http://'+ param['IP_self'] +':'+ cfg.getSetting('port_webserver')
param['HostToIntercept'] = 'trailers.apple.com'
param['HostToIntercept'] = cfg.getSetting('hosttointercept')

if len(sys.argv)==1:
Run(cmdPipe[1], param)
elif len(sys.argv)==2 and sys.argv[1]=='SSL':
Expand Down
4 changes: 2 additions & 2 deletions XMLConverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1379,8 +1379,8 @@ def ATTRIB_BACKGROUNDURL(self, src, srcXML, param):
cfg = Settings.CSettings()
param = {}
param['CSettings'] = cfg
param['HostToIntercept'] = 'trailers.apple.com'

param['HostToIntercept'] = cfg.getSetting('hosttointercept')
setParams(param)

cfg = ATVSettings.CATVSettings()
Expand Down
Binary file added assets/icons/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c737d8a

Please sign in to comment.