I identified my videofile using the hash,
I found a subtitle file using SearchSubtitles,
I found the IDSubtitleFile, and called DownloadSubtitles with that ID.
I got a datafield string back, decoded and ungzipped it, and now its only 16k.
If i search the site and locate the subtitles with that same ID its 47k..
what am I doing wrong?
here's the code:
Code: Select all
private string DownloadSubtitlesByFileId(string subtitleFileId)
{
string returnValue = string.Empty;
string[] query = new string[] {subtitleFileId};
XmlRpcStruct response = _client.DownloadSubtitles(_token, query);
object[] subtitleFiles = response["data"] as object[];
XmlRpcStruct firstSubTitleFile = subtitleFiles.FirstOrDefault() as XmlRpcStruct;
string encodedSubtitles = firstSubTitleFile["data"] as string;
byte[] zippedSubtitles = Convert.FromBase64String(encodedSubtitles);
returnValue = UnZip(zippedSubtitles);
return returnValue;
}
private string UnZip(byte[] byteArray)
{
//Prepare for decompress
System.IO.MemoryStream ms = new System.IO.MemoryStream(byteArray);
System.IO.Compression.GZipStream sr = new System.IO.Compression.GZipStream(ms,
System.IO.Compression.CompressionMode.Decompress);
//Reset variable to collect uncompressed result
byteArray = new byte[byteArray.Length];
//Decompress
int rByte = sr.Read(byteArray, 0, byteArray.Length);
//Transform byte[] unzip data to string
System.Text.StringBuilder sB = new System.Text.StringBuilder(rByte);
//Read the number of bytes GZipStream red and do not a for each bytes in
//resultByteArray;
for (int i = 0; i < rByte; i++)
{
sB.Append((char)byteArray[i]);
}
sr.Close();
ms.Close();
sr.Dispose();
ms.Dispose();
return sB.ToString();
}