3 import beacon
, httpserver
, os
, sys
5 from plugin
import GetPlugin
7 port
= config
.getPort()
9 httpd
= httpserver
.TivoHTTPServer(('', int(port
)), httpserver
.TivoHTTPHandler
)
11 for section
, settings
in config
.getShares():
12 httpd
.add_container(section
, settings
)
13 # Precaching of files: does a recursive list of base path
14 if settings
.get('precache', 'False').lower() == 'true':
15 plugin
= GetPlugin(settings
.get('type'))
16 if hasattr(plugin
, 'pre_cache'):
17 print 'Pre-caching the', section
, 'share.'
18 pre_cache_filter
= getattr(plugin
, 'pre_cache')
20 def build_recursive_list(path
):
21 for f
in os
.listdir(path
):
22 f
= os
.path
.join(path
, f
)
24 build_recursive_list(f
)
28 build_recursive_list(settings
.get('path'))
31 b
.add_service('TiVoMediaServer:' + str(port
) + '/http')
33 if 'listen' in config
.getBeaconAddresses():
36 print 'pyTivo is ready.'
39 except KeyboardInterrupt: