Exemplo n.º 1
0
def _get_primary_source_shows(config):
	debug("Retrieving primary show list")
	link_handlers = services.get_link_handlers()
	service_handlers = services.get_service_handlers()
	
	site_key = config.discovery_primary_source
	if site_key not in link_handlers:
		warning("Primary source site handler for {} not installed".format(site_key))
		return
	
	site_handler = link_handlers.get(site_key)
	shows = []
	for raw_show in site_handler.get_seasonal_shows(useragent=config.useragent):
		if raw_show.show_type is not ShowType.UNKNOWN and raw_show.show_type not in config.new_show_types:
			debug("  Show isn't an allowed type ({})".format(raw_show.show_type))
			debug("    name={}".format(raw_show.name))
			continue
		
		debug("New show: {}".format(raw_show.name))
		
		d = OrderedDict([
			("title", raw_show.name),
			("type", raw_show.show_type.name.lower()),
			("has_source", raw_show.has_source),
			("info", OrderedDict([(i, "") for i in sorted(link_handlers.keys()) if i in config.discovery_secondary_sources])),
			("streams", OrderedDict([(s, "") for s in sorted(service_handlers.keys()) if not service_handlers[s].is_generic and s in config.discovery_stream_sources]))
		])
		shows.append(d)
	
	return shows
Exemplo n.º 2
0
def _get_new_season_streams(config, db):
    handlers = services.get_service_handlers()
    for service in db.get_services():
        if service.key not in handlers:
            warning("Service handler for {} not installed".format(service.key))
            continue

        handler = handlers.get(service.key)
        info("  Checking {} ({})".format(handler.name, handler.key))
        raw_stream = handler.get_seasonal_streams(useragent=config.useragent)
        for raw_stream in raw_stream:
            yield raw_stream
Exemplo n.º 3
0
def _get_new_season_streams(config, db):
	handlers = services.get_service_handlers()
	for service in db.get_services():
		if service.key not in handlers:
			warning("Service handler for {} not installed".format(service.key))
			continue
		
		handler = handlers.get(service.key)
		info("  Checking {} ({})".format(handler.name, handler.key))
		raw_stream = handler.get_seasonal_streams(useragent=config.useragent)
		for raw_stream in raw_stream:
			yield raw_stream
Exemplo n.º 4
0
def main(config, args, extra_args):
	from logging import debug, info, warning, error, exception
	
	# Set things up
	db = database.living_in(config.database)
	if not db:
		error("Cannot continue running without a database")
		return
	
	services.setup_services(config)
	
	# Run the requested module
	try:
		debug("Running module {}".format(config.module))
		if config.module == "setup":
			info("Setting up database")
			db.setup_tables()
			info("Registering services")
			db.register_services(services.get_service_handlers())
			db.register_link_sites(services.get_link_handlers())
			db.register_poll_sites(services.get_poll_handlers())
		elif config.module == "edit":
			info("Editing database")
			import module_edit as m
			m.main(config, db, *extra_args)
		elif config.module == "episode":
			info("Finding new episodes")
			import module_find_episodes as m
			m.main(config, db, debug=config.debug)
		elif config.module == "find":
			info("Finding new shows")
			import module_find_shows as m
			if args.output[0] == "db":
				m.main(config, db, False)
			elif args.output[0] == "yaml":
				f = extra_args[0] if len(extra_args) > 0 else "find_output.yaml"
				m.main(config, db, True, output_file=f)
		elif config.module == "update":
			info("Updating shows")
			import module_update_shows as m
			m.main(config, db)
		else:
			warning("This should never happen or you broke it!")
	except:
		exception("Unknown exception or error")
		db.rollback()
	
	db.close()
Exemplo n.º 5
0
def main(config, args, extra_args):
	from logging import debug, info, warning, error, exception
	
	# Set things up
	db = database.living_in(config.database)
	if not db:
		error("Cannot continue running without a database")
		return
	
	services.setup_services(config)
	
	# Run the requested module
	try:
		debug("Running module {}".format(config.module))
		if config.module == "setup":
			info("Setting up database")
			db.setup_tables()
			info("Registering services")
			db.register_services(services.get_service_handlers())
			db.register_link_sites(services.get_link_handlers())
		elif config.module == "edit":
			info("Editing database")
			import module_edit as m
			m.main(config, db, *extra_args)
		elif config.module == "episode":
			info("Finding new episodes")
			import module_find_episodes as m
			m.main(config, db, debug=config.debug)
		elif config.module == "find":
			info("Finding new shows")
			import module_find_shows as m
			if args.output[0] == "db":
				m.main(config, db, False)
			elif args.output[0] == "yaml":
				f = extra_args[0] if len(extra_args) > 0 else "find_output.yaml"
				m.main(config, db, True, output_file=f)
		elif config.module == "update":
			info("Updating shows")
			import module_update_shows as m
			m.main(config, db)
		else:
			warning("This should never happen or you broke it!")
	except:
		exception("Unknown exception or error")
		db.rollback()
	
	db.close()
Exemplo n.º 6
0
def _get_primary_source_shows(config):
    debug("Retrieving primary show list")
    link_handlers = services.get_link_handlers()
    service_handlers = services.get_service_handlers()

    site_key = config.discovery_primary_source
    if site_key not in link_handlers:
        warning("Primary source site handler for {} not installed".format(
            site_key))
        return

    site_handler = link_handlers.get(site_key)
    shows = []
    for raw_show in site_handler.get_seasonal_shows(
            useragent=config.useragent):
        if raw_show.show_type is not ShowType.UNKNOWN and raw_show.show_type not in config.new_show_types:
            debug("  Show isn't an allowed type ({})".format(
                raw_show.show_type))
            debug("    name={}".format(raw_show.name))
            continue

        debug("New show: {}".format(raw_show.name))

        d = OrderedDict([
            ("title", raw_show.name),
            ("type", raw_show.show_type.name.lower()),
            ("has_source", raw_show.has_source),
            ("info",
             OrderedDict([(i, "") for i in sorted(link_handlers.keys())
                          if i in config.discovery_secondary_sources])),
            ("streams",
             OrderedDict([(s, "") for s in sorted(service_handlers.keys())
                          if not service_handlers[s].is_generic
                          and s in config.discovery_stream_sources]))
        ])
        shows.append(d)

    return shows