public TVDB(String apikey, DB db) throws ParserConfigurationException, SAXException, IOException
	{
		this.apikey = apikey;
		this.db = db;
		service = Client.create().resource("http://www.thetvdb.com/api");
		String mirrorsXml = service.path(this.apikey + "/mirrors.xml").accept(MediaType.TEXT_XML).get(String.class);
		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
		factory.setNamespaceAware(true);
		parser = factory.newDocumentBuilder();
		Document doc = parser.parse(new ByteArrayInputStream(mirrorsXml.getBytes()));

		NodeList mirrorsList = doc.getElementsByTagName("Mirrors");
		mirrors = Maps.newEnumMap(ResourceType.class);

		for (int i = 0; i < mirrorsList.getLength(); i++)
		{
			Node mirrorNode = mirrorsList.item(i);
			NodeList attributes = mirrorNode.getChildNodes();
			String mirrorPath = null;
			int typeMask = 0;
			for (int j = 0; j < attributes.getLength(); j++)
			{
				Node attrib = attributes.item(j);
				switch (attrib.getLocalName())
				{
					case "mirrorpath":
						mirrorPath = attrib.getNodeValue();
						break;
					case "typemask":
						typeMask = Integer.parseInt(attrib.getNodeValue());
						break;
				}
			}
			if (mirrorPath != null)
			{
				for (ResourceType resourceType : ResourceType.values())
				{
					if ((resourceType.typeMask & typeMask) == 1)
					{
						if (!mirrors.containsKey(resourceType))
						{
							mirrors.put(resourceType, Lists.<String>newArrayList());
						}

						mirrors.get(resourceType).add(mirrorPath);
					}
				}
			}
		}
	}