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
):
22 for f
in os
.listdir(path
):
23 f
= os
.path
.join(path
, f
)
25 build_recursive_list(f
)
31 build_recursive_list(settings
.get('path'))
34 b
.add_service('TiVoMediaServer:' + str(port
) + '/http')
36 if 'listen' in config
.getBeaconAddresses():
39 print 'pyTivo is ready.'
42 except KeyboardInterrupt: