@Override
	public InputStream openDownloadStream(String trackId) {

		HTTPProxy httpProxy = new YaHTTPProxy();
		YaMusicTrackInfo trackInfo = null;
		// step 1 : search for track in our trackList
		for (IMusicTrackInfo musicTrackInfo : trackList) {
			if (musicTrackInfo.getTrackId().equals(trackId)) {
				trackInfo = (YaMusicTrackInfo) musicTrackInfo;
				break;
			}
		}
		if (trackInfo == null) {
			return null;
		}

		try {
			// step 2: Get XML with file name
			String trackNameXML = httpProxy.makeRequestForString(String.format(
					"http://storage.music.yandex.ru/get/%s/2.xml",
					trackInfo.getStorageDir()));

			String fileName = HTTPProxy.getAttributeValue(trackNameXML,
					"filename");

			if (fileName == null || fileName.isEmpty()) {
				return null;
			}

			// step 3: Get XML with download info
			String downloadInfoXML = httpProxy
					.makeRequestForString(String
							.format("http://storage.music.yandex.ru/download-info/%s/%s",
									trackInfo.getStorageDir(), fileName));
			if (downloadInfoXML == null || downloadInfoXML.isEmpty()) {
				return null;
			}

			class DownloadStruct {
				public String host = "";
				public String ts = "";
				public String path = "";
				public String region = "";
				public String s = "";

				public boolean isFilled() {
					return !(host.isEmpty() || ts.isEmpty() || path.isEmpty()
							|| region.isEmpty() || s.isEmpty());
				}
			}
			;

			DownloadStruct downloadStruct = new DownloadStruct();

			downloadStruct.host = HTTPProxy.getElementInnerText(
					downloadInfoXML, "host");
			downloadStruct.path = HTTPProxy.getElementInnerText(
					downloadInfoXML, "path");
			downloadStruct.region = HTTPProxy.getElementInnerText(
					downloadInfoXML, "region");
			downloadStruct.ts = HTTPProxy.getElementInnerText(downloadInfoXML,
					"ts");
			downloadStruct.s = HTTPProxy.getElementInnerText(downloadInfoXML,
					"s");

			if (!downloadStruct.isFilled()) {
				return null;
			}

			// step 3.5 Generate secret Key
			String secretKey = new MD5Proxy().MD5("XGRlBW9FXlekgbPrRHuSiA"
					+ downloadStruct.path.substring(1) + downloadStruct.s);
			// step 4 : download request

			String downloadRequest = String
					.format("http://%s/get-mp3/%s/%s%s?track-id=%s&/region=%s&from=service-search",
							downloadStruct.host, secretKey, downloadStruct.ts,
							downloadStruct.path, trackInfo.getTrackId(),
							downloadStruct.region);

			URL u = new URL(downloadRequest);

			URLConnection uc = u.openConnection();

			InputStream is = uc.getInputStream();
			return is;

		} catch (IOException e) {
			e.printStackTrace();
		}

		return null;
	}