check in open subtitles stub

This commit is contained in:
Luke Pulverenti 2014-05-05 00:36:45 -04:00
parent 8aadbf3513
commit ac69327f1f
72 changed files with 6347 additions and 17 deletions

View File

@ -230,10 +230,11 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
var httpWebRequest = GetRequest(options, httpMethod, options.EnableHttpCompression); var httpWebRequest = GetRequest(options, httpMethod, options.EnableHttpCompression);
if (!string.IsNullOrEmpty(options.RequestContent) || string.Equals(httpMethod, "post", StringComparison.OrdinalIgnoreCase)) if (options.RequestContentBytes != null ||
!string.IsNullOrEmpty(options.RequestContent) ||
string.Equals(httpMethod, "post", StringComparison.OrdinalIgnoreCase))
{ {
var content = options.RequestContent ?? string.Empty; var bytes = options.RequestContentBytes ?? Encoding.UTF8.GetBytes(options.RequestContent ?? string.Empty);
var bytes = Encoding.UTF8.GetBytes(content);
httpWebRequest.ContentType = options.RequestContentType ?? "application/x-www-form-urlencoded"; httpWebRequest.ContentType = options.RequestContentType ?? "application/x-www-form-urlencoded";
httpWebRequest.ContentLength = bytes.Length; httpWebRequest.ContentLength = bytes.Length;

View File

@ -69,6 +69,7 @@ namespace MediaBrowser.Common.Net
public string RequestContentType { get; set; } public string RequestContentType { get; set; }
public string RequestContent { get; set; } public string RequestContent { get; set; }
public byte[] RequestContentBytes { get; set; }
public bool BufferContent { get; set; } public bool BufferContent { get; set; }

View File

@ -191,6 +191,7 @@
<Compile Include="Providers\IMetadataProvider.cs" /> <Compile Include="Providers\IMetadataProvider.cs" />
<Compile Include="Providers\IMetadataService.cs" /> <Compile Include="Providers\IMetadataService.cs" />
<Compile Include="Providers\IRemoteMetadataProvider.cs" /> <Compile Include="Providers\IRemoteMetadataProvider.cs" />
<Compile Include="Providers\ISubtitleProvider.cs" />
<Compile Include="Providers\ItemLookupInfo.cs" /> <Compile Include="Providers\ItemLookupInfo.cs" />
<Compile Include="Providers\MetadataRefreshOptions.cs" /> <Compile Include="Providers\MetadataRefreshOptions.cs" />
<Compile Include="Providers\NameParser.cs" /> <Compile Include="Providers\NameParser.cs" />

View File

@ -0,0 +1,55 @@
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Controller.Providers
{
public interface ISubtitleProvider
{
/// <summary>
/// Gets the name.
/// </summary>
/// <value>The name.</value>
string Name { get; }
/// <summary>
/// Gets the supported media types.
/// </summary>
/// <value>The supported media types.</value>
IEnumerable<SubtitleMediaType> SupportedMediaTypes { get; }
/// <summary>
/// Gets the subtitles.
/// </summary>
/// <param name="request">The request.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task{SubtitleResponse}.</returns>
Task<SubtitleResponse> GetSubtitles(SubtitleRequest request, CancellationToken cancellationToken);
}
public enum SubtitleMediaType
{
Episode = 0,
Movie = 1
}
public class SubtitleResponse
{
public string Format { get; set; }
public bool HasContent { get; set; }
public Stream Stream { get; set; }
}
public class SubtitleRequest
{
public string Language { get; set; }
public SubtitleMediaType ContentType { get; set; }
public string MediaPath { get; set; }
public string SeriesName { get; set; }
public int? IndexNumber { get; set; }
public int? ParentIndexNumber { get; set; }
}
}

View File

@ -3,22 +3,27 @@ namespace MediaBrowser.Model.MediaInfo
{ {
public class Container public class Container
{ {
public string MP4 = "MP4"; public const string MP4 = "MP4";
} }
public class AudioCodec public class AudioCodec
{ {
public string AAC = "AAC"; public const string AAC = "AAC";
public string MP3 = "MP3"; public const string MP3 = "MP3";
} }
public class VideoCodec public class VideoCodec
{ {
public string H263 = "H263"; public const string H263 = "H263";
public string H264 = "H264"; public const string H264 = "H264";
public string H265 = "H265"; public const string H265 = "H265";
public string MPEG4 = "MPEG4"; public const string MPEG4 = "MPEG4";
public string MSMPEG4 = "MSMPEG4"; public const string MSMPEG4 = "MSMPEG4";
public string VC1 = "VC1"; public const string VC1 = "VC1";
}
public class SubtitleFormat
{
public const string SRT = "SRT";
} }
} }

View File

@ -186,6 +186,7 @@
<Compile Include="Savers\XmlSaverHelpers.cs" /> <Compile Include="Savers\XmlSaverHelpers.cs" />
<Compile Include="Studios\StudiosImageProvider.cs" /> <Compile Include="Studios\StudiosImageProvider.cs" />
<Compile Include="Studios\StudioMetadataService.cs" /> <Compile Include="Studios\StudioMetadataService.cs" />
<Compile Include="Subtitles\OpenSubtitleDownloader.cs" />
<Compile Include="TV\EpisodeLocalImageProvider.cs" /> <Compile Include="TV\EpisodeLocalImageProvider.cs" />
<Compile Include="TV\EpisodeMetadataService.cs" /> <Compile Include="TV\EpisodeMetadataService.cs" />
<Compile Include="TV\EpisodeXmlProvider.cs" /> <Compile Include="TV\EpisodeXmlProvider.cs" />
@ -229,6 +230,10 @@
<Project>{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}</Project> <Project>{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}</Project>
<Name>MediaBrowser.Model</Name> <Name>MediaBrowser.Model</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\OpenSubtitlesHandler\OpenSubtitlesHandler.csproj">
<Project>{4a4402d4-e910-443b-b8fc-2c18286a2ca0}</Project>
<Name>OpenSubtitlesHandler</Name>
</ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <None Include="packages.config" />

View File

@ -0,0 +1,132 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.MediaInfo;
using OpenSubtitlesHandler;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Providers.Subtitles
{
public class OpenSubtitleDownloader : ISubtitleProvider
{
private readonly ILogger _logger;
private readonly IHttpClient _httpClient;
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
public OpenSubtitleDownloader(ILogger logger, IHttpClient httpClient)
{
_logger = logger;
_httpClient = httpClient;
}
public string Name
{
get { return "Open Subtitles"; }
}
public IEnumerable<SubtitleMediaType> SupportedMediaTypes
{
get { return new[] { SubtitleMediaType.Episode, SubtitleMediaType.Movie }; }
}
public Task<SubtitleResponse> GetSubtitles(SubtitleRequest request, CancellationToken cancellationToken)
{
return request.ContentType == SubtitleMediaType.Episode
? GetEpisodeSubtitles(request, cancellationToken)
: GetMovieSubtitles(request, cancellationToken);
}
public async Task<SubtitleResponse> GetMovieSubtitles(SubtitleRequest request, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
public async Task<SubtitleResponse> GetEpisodeSubtitles(SubtitleRequest request, CancellationToken cancellationToken)
{
var response = new SubtitleResponse();
if (!request.IndexNumber.HasValue || !request.ParentIndexNumber.HasValue)
{
_logger.Debug("Information Missing");
return response;
}
if (string.IsNullOrEmpty(request.MediaPath))
{
_logger.Debug("Path Missing");
return response;
}
Utilities.HttpClient = _httpClient;
OpenSubtitles.SetUserAgent("OS Test User Agent");
var loginResponse = OpenSubtitles.LogIn("", "", "en");
if (!(loginResponse is MethodResponseLogIn))
{
_logger.Debug("Login error");
return response;
}
var subLanguageId = request.Language;
var hash = Utilities.ComputeHash(request.MediaPath);
var fileInfo = new FileInfo(request.MediaPath);
var movieByteSize = fileInfo.Length;
var parms = new List<SubtitleSearchParameters> {
new SubtitleSearchParameters(subLanguageId, hash, movieByteSize),
new SubtitleSearchParameters(subLanguageId, request.SeriesName, request.ParentIndexNumber.Value.ToString(_usCulture), request.IndexNumber.Value.ToString(_usCulture)),
};
var result = OpenSubtitles.SearchSubtitles(parms.ToArray());
if (!(result is MethodResponseSubtitleSearch))
{
_logger.Debug("invalid response type");
return null;
}
var results = ((MethodResponseSubtitleSearch)result).Results;
var bestResult = results.Where(x => x.SubBad == "0" && int.Parse(x.SeriesSeason) == request.ParentIndexNumber && int.Parse(x.SeriesEpisode) == request.IndexNumber)
.OrderBy(x => x.MovieHash == hash)
.ThenBy(x => Math.Abs(long.Parse(x.MovieByteSize) - movieByteSize))
.ThenByDescending(x => int.Parse(x.SubDownloadsCnt))
.ThenByDescending(x => double.Parse(x.SubRating))
.ToList();
if (!bestResult.Any())
{
_logger.Debug("No Subtitles");
return response;
}
_logger.Debug("Found " + bestResult.Count + " subtitles.");
var subtitle = bestResult.First();
var downloadsList = new[] { int.Parse(subtitle.IDSubtitleFile) };
var resultDownLoad = OpenSubtitles.DownloadSubtitles(downloadsList);
if (!(resultDownLoad is MethodResponseSubtitleDownload))
{
_logger.Debug("invalid response type");
return response;
}
if (!((MethodResponseSubtitleDownload)resultDownLoad).Results.Any())
{
_logger.Debug("No Subtitle Downloads");
return response;
}
var res = ((MethodResponseSubtitleDownload)resultDownLoad).Results.First();
var data = Convert.FromBase64String(res.Data);
response.HasContent = true;
response.Format = SubtitleFormat.SRT;
response.Stream = new MemoryStream(Utilities.Decompress(new MemoryStream(data)));
return response;
}
}
}

View File

@ -1026,16 +1026,12 @@ namespace MediaBrowser.ServerApplication
/// <returns>Task{CheckForUpdateResult}.</returns> /// <returns>Task{CheckForUpdateResult}.</returns>
public override async Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress<double> progress) public override async Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress<double> progress)
{ {
#if DEBUG
return new CheckForUpdateResult { AvailableVersion = ApplicationVersion, IsUpdateAvailable = false };
#endif
var availablePackages = await InstallationManager.GetAvailablePackagesWithoutRegistrationInfo(cancellationToken).ConfigureAwait(false); var availablePackages = await InstallationManager.GetAvailablePackagesWithoutRegistrationInfo(cancellationToken).ConfigureAwait(false);
var version = InstallationManager.GetLatestCompatibleVersion(availablePackages, Constants.MbServerPkgName, null, ApplicationVersion, var version = InstallationManager.GetLatestCompatibleVersion(availablePackages, Constants.MbServerPkgName, null, ApplicationVersion,
ConfigurationManager.CommonConfiguration.SystemUpdateLevel); ConfigurationManager.CommonConfiguration.SystemUpdateLevel);
HasUpdateAvailable = version != null; HasUpdateAvailable = version != null && version.version >= ApplicationVersion;
return version != null ? new CheckForUpdateResult { AvailableVersion = version.version, IsUpdateAvailable = version.version > ApplicationVersion, Package = version } : return version != null ? new CheckForUpdateResult { AvailableVersion = version.version, IsUpdateAvailable = version.version > ApplicationVersion, Package = version } :
new CheckForUpdateResult { AvailableVersion = ApplicationVersion, IsUpdateAvailable = false }; new CheckForUpdateResult { AvailableVersion = ApplicationVersion, IsUpdateAvailable = false };

View File

@ -43,6 +43,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Dlna", "MediaB
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.MediaEncoding", "MediaBrowser.MediaEncoding\MediaBrowser.MediaEncoding.csproj", "{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.MediaEncoding", "MediaBrowser.MediaEncoding\MediaBrowser.MediaEncoding.csproj", "{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSubtitlesHandler", "OpenSubtitlesHandler\OpenSubtitlesHandler.csproj", "{4A4402D4-E910-443B-B8FC-2C18286A2CA0}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -263,6 +265,20 @@ Global
{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Release|Win32.ActiveCfg = Release|Any CPU {0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Release|Win32.ActiveCfg = Release|Any CPU
{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Release|x64.ActiveCfg = Release|Any CPU {0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Release|x64.ActiveCfg = Release|Any CPU
{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Release|x86.ActiveCfg = Release|Any CPU {0BD82FA6-EB8A-4452-8AF5-74F9C3849451}.Release|x86.ActiveCfg = Release|Any CPU
{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Debug|Win32.ActiveCfg = Debug|Any CPU
{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Debug|x64.ActiveCfg = Debug|Any CPU
{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Debug|x86.ActiveCfg = Debug|Any CPU
{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Release|Any CPU.Build.0 = Release|Any CPU
{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Release|Win32.ActiveCfg = Release|Any CPU
{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Release|x64.ActiveCfg = Release|Any CPU
{4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -0,0 +1,92 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
namespace OpenSubtitlesHandler.Console
{
public class OSHConsole
{
/// <summary>
/// Write line to the console and raise the "LineWritten" event
/// </summary>
///
/// <param name="text">The debug line</param>
/// <param name="code">The status</param>
public static void WriteLine(string text, DebugCode code = DebugCode.None)
{
if (LineWritten != null)
LineWritten(null, new DebugEventArgs(text, code));
}
/// <summary>
/// Update the last written line
/// </summary>
/// <param name="text">The debug line</param>
/// <param name="code">The status</param>
public static void UpdateLine(string text, DebugCode code = DebugCode.None)
{
if (UpdateLastLine != null)
UpdateLastLine(null, new DebugEventArgs(text, code));
}
public static event EventHandler<DebugEventArgs> LineWritten;
public static event EventHandler<DebugEventArgs> UpdateLastLine;
}
public enum DebugCode
{
None,
Good,
Warning,
Error
}
/// <summary>
/// Console Debug Args
/// </summary>
public class DebugEventArgs : System.EventArgs
{
public DebugCode Code { get; private set; }
public string Text { get; private set; }
/// <summary>
/// Console Debug Args
/// </summary>
/// <param name="text">The debug line</param>
/// <param name="code">The status</param>
public DebugEventArgs(string text, DebugCode code)
{
this.Text = text;
this.Code = code;
}
}
public struct DebugLine
{
public DebugLine(string debugLine, DebugCode status)
{
this.debugLine = debugLine;
this.status = status;
}
string debugLine;
DebugCode status;
public string Text
{ get { return debugLine; } set { debugLine = value; } }
public DebugCode Code
{ get { return status; } set { status = value; } }
}
}

View File

@ -0,0 +1,62 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.ComponentModel;
namespace OpenSubtitlesHandler
{
/// <summary>
/// When you call a method to communicate with OpenSubtitles server, that method should return this response with the reuired information.
/// </summary>
public abstract class IMethodResponse
{
public IMethodResponse() { LoadAttributes(); }
public IMethodResponse(string name, string message)
{
this.name = name;
this.message = message;
}
protected string name;
protected string message;
protected double seconds;
protected string status;
protected virtual void LoadAttributes()
{
foreach (Attribute attr in Attribute.GetCustomAttributes(this.GetType()))
{
if (attr.GetType() == typeof(MethodResponseDescription))
{
this.name = ((MethodResponseDescription)attr).Name;
this.message = ((MethodResponseDescription)attr).Message;
break;
}
}
}
[Description("The name of this response"), Category("MethodResponse")]
public virtual string Name { get { return name; } set { name = value; } }
[Description("The message about this response"), Category("MethodResponse")]
public virtual string Message { get { return message; } set { message = value; } }
[Description("Time taken to execute this command on server"), Category("MethodResponse")]
public double Seconds { get { return seconds; } set { seconds = value; } }
[Description("The status"), Category("MethodResponse")]
public string Status { get { return status; } set { status = value; } }
}
}

View File

@ -0,0 +1,40 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
namespace OpenSubtitlesHandler
{
/// <summary>
/// Attributes to describe a method response object.
/// </summary>
public class MethodResponseDescription : Attribute
{
public MethodResponseDescription(string name, string message)
{
this.name = name;
this.message = message;
}
private string name;
private string message;
public string Name { get { return name; } set { name = value; } }
public string Message { get { return message; } set { message = value; } }
}
}

View File

@ -0,0 +1,31 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace OpenSubtitlesHandler
{
public struct DetectLanguageResult
{
private string inputSample;
private string languageID;
public string LanguageID
{ get { return languageID; } set { languageID = value; } }
public string InputSample
{ get { return inputSample; } set { inputSample = value; } }
}
}

View File

@ -0,0 +1,32 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace OpenSubtitlesHandler
{
[MethodResponseDescription("AddComment method response",
"AddComment method response hold all expected values from server.")]
public class MethodResponseAddComment : IMethodResponse
{
public MethodResponseAddComment()
: base()
{ }
public MethodResponseAddComment(string name, string message)
: base(name, message)
{ }
}
}

View File

@ -0,0 +1,35 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace OpenSubtitlesHandler
{
[MethodResponseDescription("AddRequest method response",
"AddRequest method response hold all expected values from server.")]
public class MethodResponseAddRequest : IMethodResponse
{
public MethodResponseAddRequest()
: base()
{ }
public MethodResponseAddRequest(string name, string message)
: base(name, message)
{ }
private string _request_url;
public string request_url { get { return _request_url; } set { _request_url = value; } }
}
}

View File

@ -0,0 +1,60 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.ComponentModel;
namespace OpenSubtitlesHandler
{
[MethodResponseDescription("AutoUpdate method response",
"AutoUpdate method response hold all expected values from server.")]
public class MethodResponseAutoUpdate : IMethodResponse
{
public MethodResponseAutoUpdate()
: base()
{ }
public MethodResponseAutoUpdate(string name, string message)
: base(name, message)
{ }
private string _version;
private string _url_windows;
private string _comments;
private string _url_linux;
/// <summary>
/// Latest application version
/// </summary>
[Description("Latest application version"), Category("AutoUpdate")]
public string version { get { return _version; } set { _version = value; } }
/// <summary>
/// Download URL for Windows version
/// </summary>
[Description("Download URL for Windows version"), Category("AutoUpdate")]
public string url_windows { get { return _url_windows; } set { _url_windows = value; } }
/// <summary>
/// Application changelog and other comments
/// </summary>
[Description("Application changelog and other comments"), Category("AutoUpdate")]
public string comments { get { return _comments; } set { _comments = value; } }
/// <summary>
/// Download URL for Linux version
/// </summary>
[Description("Download URL for Linux version"), Category("AutoUpdate")]
public string url_linux { get { return _url_linux; } set { _url_linux = value; } }
}
}

View File

@ -0,0 +1,37 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
namespace OpenSubtitlesHandler
{
[MethodResponseDescription("CheckMovieHash method response",
"CheckMovieHash method response hold all expected values from server.")]
public class MethodResponseCheckMovieHash : IMethodResponse
{
public MethodResponseCheckMovieHash()
: base()
{ }
public MethodResponseCheckMovieHash(string name, string message)
: base(name, message)
{ }
private List<CheckMovieHashResult> results = new List<CheckMovieHashResult>();
public List<CheckMovieHashResult> Results
{ get { return results; } set { results = value; } }
}
}

View File

@ -0,0 +1,37 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
namespace OpenSubtitlesHandler
{
[MethodResponseDescription("CheckMovieHash2 method response",
"CheckMovieHash2 method response hold all expected values from server.")]
public class MethodResponseCheckMovieHash2 : IMethodResponse
{
public MethodResponseCheckMovieHash2()
: base()
{ }
public MethodResponseCheckMovieHash2(string name, string message)
: base(name, message)
{ }
private List<CheckMovieHash2Result> results = new List<CheckMovieHash2Result>();
public List<CheckMovieHash2Result> Results
{ get { return results; } set { results = value; } }
}
}

View File

@ -0,0 +1,38 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
namespace OpenSubtitlesHandler
{
[MethodResponseDescription("CheckSubHash method response",
"CheckSubHash method response hold all expected values from server.")]
public class MethodResponseCheckSubHash : IMethodResponse
{
public MethodResponseCheckSubHash()
: base()
{ }
public MethodResponseCheckSubHash(string name, string message)
: base(name, message)
{ }
private List<CheckSubHashResult> results = new List<CheckSubHashResult>();
public List<CheckSubHashResult> Results { get { return results; } set { results = value; } }
}
}

View File

@ -0,0 +1,37 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.Collections.Generic;
namespace OpenSubtitlesHandler
{
[MethodResponseDescription("DetectLanguage method response",
"DetectLanguage method response hold all expected values from server.")]
public class MethodResponseDetectLanguage : IMethodResponse
{
public MethodResponseDetectLanguage()
: base()
{ }
public MethodResponseDetectLanguage(string name, string message)
: base(name, message)
{ }
private List<DetectLanguageResult> results = new List<DetectLanguageResult>();
public List<DetectLanguageResult> Results
{ get { return results; } set { results = value; } }
}
}

View File

@ -0,0 +1,36 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
namespace OpenSubtitlesHandler
{
/// <summary>
/// Response that can be used for general error like internet connection fail.
/// </summary>
[MethodResponseDescription("Error method response",
"Error method response that describes error that occured")]
public class MethodResponseError : IMethodResponse
{
public MethodResponseError()
: base()
{ }
public MethodResponseError(string name, string message)
: base(name, message)
{ }
}
}

View File

@ -0,0 +1,37 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
namespace OpenSubtitlesHandler
{
[MethodResponseDescription("GetAvailableTranslations method response",
"GetAvailableTranslations method response hold all expected values from server.")]
public class MethodResponseGetAvailableTranslations : IMethodResponse
{
public MethodResponseGetAvailableTranslations()
: base()
{ }
public MethodResponseGetAvailableTranslations(string name, string message)
: base(name, message)
{ }
private List<GetAvailableTranslationsResult> results = new List<GetAvailableTranslationsResult>();
public List<GetAvailableTranslationsResult> Results { get { return results; } set { results = value; } }
}
}

View File

@ -0,0 +1,41 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OpenSubtitlesHandler
{
[MethodResponseDescription("GetComments method response",
"GetComments method response hold all expected values from server.")]
public class MethodResponseGetComments : IMethodResponse
{
public MethodResponseGetComments()
: base()
{ }
public MethodResponseGetComments(string name, string message)
: base(name, message)
{ }
private List<GetCommentsResult> results = new List<GetCommentsResult>();
public List<GetCommentsResult> Results
{ get { return results; } set { results = value; } }
}
}

View File

@ -0,0 +1,39 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
namespace OpenSubtitlesHandler
{
[MethodResponseDescription("GetSubLanguages method response",
"GetSubLanguages method response hold all expected values from server.")]
public class MethodResponseGetSubLanguages : IMethodResponse
{
public MethodResponseGetSubLanguages()
: base()
{ }
public MethodResponseGetSubLanguages(string name, string message)
: base(name, message)
{ }
private List<SubtitleLanguage> languages = new List<SubtitleLanguage>();
public List<SubtitleLanguage> Languages
{ get { return languages; } set { languages = value; } }
}
}

View File

@ -0,0 +1,37 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
namespace OpenSubtitlesHandler
{
[MethodResponseDescription("GetTranslation method response",
"GetTranslation method response hold all expected values from server.")]
public class MethodResponseGetTranslation : IMethodResponse
{
public MethodResponseGetTranslation()
: base()
{ }
public MethodResponseGetTranslation(string name, string message)
: base(name, message)
{ }
private string data;
public string ContentData { get { return data; } set { data = value; } }
}
}

View File

@ -0,0 +1,37 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
namespace OpenSubtitlesHandler
{
[MethodResponseDescription("InsertMovie method response",
"InsertMovie method response hold all expected values from server.")]
public class MethodResponseInsertMovie : IMethodResponse
{
public MethodResponseInsertMovie()
: base()
{ }
public MethodResponseInsertMovie(string name, string message)
: base(name, message)
{ }
private string _ID;
public string ID
{ get { return _ID; } set { _ID = value; } }
}
}

View File

@ -0,0 +1,38 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.Collections.Generic;
namespace OpenSubtitlesHandler
{
[MethodResponseDescription("InsertMovieHash method response",
"InsertMovieHash method response hold all expected values from server.")]
public class MethodResponseInsertMovieHash : IMethodResponse
{
public MethodResponseInsertMovieHash()
: base()
{ }
public MethodResponseInsertMovieHash(string name, string message)
: base(name, message)
{ }
private List<string> _accepted_moviehashes = new List<string>();
private List<string> _new_imdbs = new List<string>();
public List<string> accepted_moviehashes { get { return _accepted_moviehashes; } set { _accepted_moviehashes = value; } }
public List<string> new_imdbs { get { return _new_imdbs; } set { _new_imdbs = value; } }
}
}

View File

@ -0,0 +1,40 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
namespace OpenSubtitlesHandler
{
/// <summary>
/// Response can be used for log in/out operation.
/// </summary>
[MethodResponseDescription("LogIn method response",
"LogIn method response hold all expected values from server.")]
public class MethodResponseLogIn : IMethodResponse
{
public MethodResponseLogIn()
: base()
{ }
public MethodResponseLogIn(string name, string message)
: base(name, message)
{ }
private string token;
public string Token { get { return token; } set { token = value; } }
}
}

View File

@ -0,0 +1,73 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
namespace OpenSubtitlesHandler
{
[MethodResponseDescription("MovieDetails method response",
"MovieDetails method response hold all expected values from server.")]
public class MethodResponseMovieDetails : IMethodResponse
{
public MethodResponseMovieDetails()
: base()
{ }
public MethodResponseMovieDetails(string name, string message)
: base(name, message)
{ }
// Details
private string id;
private string title;
private string year;
private string coverLink;
private string duration;
private string tagline;
private string plot;
private string goofs;
private string trivia;
private List<string> cast = new List<string>();
private List<string> directors = new List<string>();
private List<string> writers = new List<string>();
private List<string> awards = new List<string>();
private List<string> genres = new List<string>();
private List<string> country = new List<string>();
private List<string> language = new List<string>();
private List<string> certification = new List<string>();
// Details
public string ID { get { return id; } set { id = value; } }
public string Title { get { return title; } set { title = value; } }
public string Year { get { return year; } set { year = value; } }
public string CoverLink { get { return coverLink; } set { coverLink = value; } }
public string Duration { get { return duration; } set { duration = value; } }
public string Tagline { get { return tagline; } set { tagline = value; } }
public string Plot { get { return plot; } set { plot = value; } }
public string Goofs { get { return goofs; } set { goofs = value; } }
public string Trivia { get { return trivia; } set { trivia = value; } }
public List<string> Cast { get { return cast; } set { cast = value; } }
public List<string> Directors { get { return directors; } set { directors = value; } }
public List<string> Writers { get { return writers; } set { writers = value; } }
public List<string> Genres { get { return genres; } set { genres = value; } }
public List<string> Awards { get { return awards; } set { awards = value; } }
public List<string> Country { get { return country; } set { country = value; } }
public List<string> Language { get { return language; } set { language = value; } }
public List<string> Certification { get { return certification; } set { certification = value; } }
}
}

View File

@ -0,0 +1,43 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
namespace OpenSubtitlesHandler
{
[MethodResponseDescription("MovieSearch method response",
"MovieSearch method response hold all expected values from server.")]
public class MethodResponseMovieSearch : IMethodResponse
{
public MethodResponseMovieSearch()
: base()
{
results = new List<MovieSearchResult>();
}
public MethodResponseMovieSearch(string name, string message)
: base(name, message)
{
results = new List<MovieSearchResult>();
}
private List<MovieSearchResult> results;
public List<MovieSearchResult> Results
{ get { return results; } set { results = value; } }
}
}

View File

@ -0,0 +1,53 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
namespace OpenSubtitlesHandler
{
[MethodResponseDescription("NoOperation method response",
"NoOperation method response hold all expected values from server.")]
public class MethodResponseNoOperation : IMethodResponse
{
public MethodResponseNoOperation()
: base() { }
public MethodResponseNoOperation(string name, string message)
: base(name, message)
{ }
private string _global_wrh_download_limit;
private string _client_ip;
private string _limit_check_by;
private string _client_24h_download_count;
private string _client_downlaod_quota;
private string _client_24h_download_limit;
public string global_wrh_download_limit
{ get { return _global_wrh_download_limit; } set { _global_wrh_download_limit = value; } }
public string client_ip
{ get { return _client_ip; } set { _client_ip = value; } }
public string limit_check_by
{ get { return _limit_check_by; } set { _limit_check_by = value; } }
public string client_24h_download_count
{ get { return _client_24h_download_count; } set { _client_24h_download_count = value; } }
public string client_downlaod_quota
{ get { return _client_downlaod_quota; } set { _client_downlaod_quota = value; } }
public string client_24h_download_limit
{ get { return _client_24h_download_limit; } set { _client_24h_download_limit = value; } }
}
}

View File

@ -0,0 +1,33 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace OpenSubtitlesHandler
{
[MethodResponseDescription("ReportWrongImdbMovie method response",
"ReportWrongImdbMovie method response hold all expected values from server.")]
public class MethodResponseReportWrongImdbMovie : IMethodResponse
{
public MethodResponseReportWrongImdbMovie()
: base()
{ }
public MethodResponseReportWrongImdbMovie(string name, string message)
: base(name, message)
{ }
}
}

View File

@ -0,0 +1,34 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
namespace OpenSubtitlesHandler
{
[MethodResponseDescription("ReportWrongMovieHash method response",
"ReportWrongMovieHash method response hold all expected values from server.")]
public class MethodResponseReportWrongMovieHash : IMethodResponse
{
public MethodResponseReportWrongMovieHash()
: base()
{ }
public MethodResponseReportWrongMovieHash(string name, string message)
: base(name, message)
{ }
}
}

View File

@ -0,0 +1,32 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace OpenSubtitlesHandler
{
[MethodResponseDescription("SearchToMail method response",
"SearchToMail method response hold all expected values from server.")]
public class MethodResponseSearchToMail : IMethodResponse
{
public MethodResponseSearchToMail()
: base()
{ }
public MethodResponseSearchToMail(string name, string message)
: base(name, message)
{ }
}
}

View File

@ -0,0 +1,132 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
namespace OpenSubtitlesHandler
{
[MethodResponseDescription("ServerInfo method response",
"ServerInfo method response hold all expected values from server.")]
public class MethodResponseServerInfo : IMethodResponse
{
public MethodResponseServerInfo()
: base()
{ }
public MethodResponseServerInfo(string name, string message)
: base(name, message)
{ }
private string _xmlrpc_version;
private string _xmlrpc_url;
private string _application;
private string _contact;
private string _website_url;
private int _users_online_total;
private int _users_online_program;
private int _users_loggedin;
private string _users_max_alltime;
private string _users_registered;
private string _subs_downloads;
private string _subs_subtitle_files;
private string _movies_total;
private string _movies_aka;
private string _total_subtitles_languages;
private List<string> _last_update_strings = new List<string>();
/// <summary>
/// Version of server's XML-RPC API implementation
/// </summary>
[Description("Version of server's XML-RPC API implementation"), Category("OS")]
public string xmlrpc_version { get { return _xmlrpc_version; } set { _xmlrpc_version = value; } }
/// <summary>
/// XML-RPC interface URL
/// </summary>
[Description("XML-RPC interface URL"), Category("OS")]
public string xmlrpc_url { get { return _xmlrpc_url; } set { _xmlrpc_url = value; } }
/// <summary>
/// Server's application name and version
/// </summary>
[Description("Server's application name and version"), Category("OS")]
public string application { get { return _application; } set { _application = value; } }
/// <summary>
/// Contact e-mail address for server related quuestions and problems
/// </summary>
[Description("Contact e-mail address for server related quuestions and problems"), Category("OS")]
public string contact { get { return _contact; } set { _contact = value; } }
/// <summary>
/// Main server URL
/// </summary>
[Description("Main server URL"), Category("OS")]
public string website_url { get { return _website_url; } set { _website_url = value; } }
/// <summary>
/// Number of users currently online
/// </summary>
[Description("Number of users currently online"), Category("OS")]
public int users_online_total { get { return _users_online_total; } set { _users_online_total = value; } }
/// <summary>
/// Number of users currently online using a client application (XML-RPC API)
/// </summary>
[Description("Number of users currently online using a client application (XML-RPC API)"), Category("OS")]
public int users_online_program { get { return _users_online_program; } set { _users_online_program = value; } }
/// <summary>
/// Number of currently logged-in users
/// </summary>
[Description("Number of currently logged-in users"), Category("OS")]
public int users_loggedin { get { return _users_loggedin; } set { _users_loggedin = value; } }
/// <summary>
/// Maximum number of users throughout the history
/// </summary>
[Description("Maximum number of users throughout the history"), Category("OS")]
public string users_max_alltime { get { return _users_max_alltime; } set { _users_max_alltime = value; } }
/// <summary>
/// Number of registered users
/// </summary>
[Description("Number of registered users"), Category("OS")]
public string users_registered { get { return _users_registered; } set { _users_registered = value; } }
/// <summary>
/// Total number of subtitle downloads
/// </summary>
[Description("Total number of subtitle downloads"), Category("OS")]
public string subs_downloads { get { return _subs_downloads; } set { _subs_downloads = value; } }
/// <summary>
/// Total number of subtitle files stored on the server
/// </summary>
[Description("Total number of subtitle files stored on the server"), Category("OS")]
public string subs_subtitle_files { get { return _subs_subtitle_files; } set { _subs_subtitle_files = value; } }
/// <summary>
/// Total number of movies in the database
/// </summary>
[Description("Total number of movies in the database"), Category("OS")]
public string movies_total { get { return _movies_total; } set { _movies_total = value; } }
/// <summary>
/// Total number of movie A.K.A. titles in the database
/// </summary>
[Description("Total number of movie A.K.A. titles in the database"), Category("OS")]
public string movies_aka { get { return _movies_aka; } set { _movies_aka = value; } }
/// <summary>
/// Total number of subtitle languages supported
/// </summary>
[Description("Total number of subtitle languages supported"), Category("OS")]
public string total_subtitles_languages { get { return _total_subtitles_languages; } set { _total_subtitles_languages = value; } }
/// <summary>
/// Structure containing information about last updates of translations.
/// </summary>
[Description("Structure containing information about last updates of translations"), Category("OS")]
public List<string> last_update_strings { get { return _last_update_strings; } set { _last_update_strings = value; } }
}
}

View File

@ -0,0 +1,44 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
namespace OpenSubtitlesHandler
{
/// <summary>
/// The response that should be used by subtitle download methods.
/// </summary>
[MethodResponseDescription("SubtitleDownload method response",
"SubtitleDownload method response hold all expected values from server.")]
public class MethodResponseSubtitleDownload : IMethodResponse
{
public MethodResponseSubtitleDownload()
: base()
{
results = new List<SubtitleDownloadResult>();
}
public MethodResponseSubtitleDownload(string name, string message)
: base(name, message)
{
results = new List<SubtitleDownloadResult>();
}
private List<SubtitleDownloadResult> results;
public List<SubtitleDownloadResult> Results
{ get { return results; } set { results = value; } }
}
}

View File

@ -0,0 +1,46 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
namespace OpenSubtitlesHandler
{
/// <summary>
/// Response to SearchSubtitle successed call.
/// </summary>
[MethodResponseDescription("SubtitleSearch method response",
"SubtitleSearch method response hold all expected values from server.")]
public class MethodResponseSubtitleSearch : IMethodResponse
{
public MethodResponseSubtitleSearch()
: base()
{
results = new List<SubtitleSearchResult>();
}
public MethodResponseSubtitleSearch(string name, string message)
: base(name, message)
{
results = new List<SubtitleSearchResult>();
}
private List<SubtitleSearchResult> results;
public List<SubtitleSearchResult> Results
{ get { return results; } set { results = value; } }
}
}

View File

@ -0,0 +1,44 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
namespace OpenSubtitlesHandler
{
[MethodResponseDescription("SubtitlesVote method response",
"SubtitlesVote method response hold all expected values from server.")]
public class MethodResponseSubtitlesVote : IMethodResponse
{
public MethodResponseSubtitlesVote()
: base()
{ }
public MethodResponseSubtitlesVote(string name, string message)
: base(name, message)
{ }
private string _SubRating;
private string _SubSumVotes;
private string _IDSubtitle;
public string SubRating
{ get { return _SubRating; } set { _SubRating = value; } }
public string SubSumVotes
{ get { return _SubSumVotes; } set { _SubSumVotes = value; } }
public string IDSubtitle
{ get { return _IDSubtitle; } set { _IDSubtitle = value; } }
}
}

View File

@ -0,0 +1,40 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
namespace OpenSubtitlesHandler
{
[MethodResponseDescription("TryUploadSubtitles method response",
"TryUploadSubtitles method response hold all expected values from server.")]
public class MethodResponseTryUploadSubtitles : IMethodResponse
{
public MethodResponseTryUploadSubtitles()
: base()
{ }
public MethodResponseTryUploadSubtitles(string name, string message)
: base(name, message)
{ }
private int alreadyindb;
private List<SubtitleSearchResult> results = new List<SubtitleSearchResult>();
public int AlreadyInDB { get { return alreadyindb; } set { alreadyindb = value; } }
public List<SubtitleSearchResult> Results { get { return results; } set { results = value; } }
}
}

View File

@ -0,0 +1,39 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
namespace OpenSubtitlesHandler
{
[MethodResponseDescription("UploadSubtitles method response",
"UploadSubtitles method response hold all expected values from server.")]
public class MethodResponseUploadSubtitles : IMethodResponse
{
public MethodResponseUploadSubtitles()
: base()
{ }
public MethodResponseUploadSubtitles(string name, string message)
: base(name, message)
{ }
private string _data;
private bool _subtitles;
public string Data { get { return _data; } set { _data = value; } }
public bool SubTitles { get { return _subtitles; } set { _subtitles = value; } }
}
}

View File

@ -0,0 +1,39 @@
List of available OpenSubtitles.org server XML-RPC methods.
==========================================================
Legends:
* OK: this method is fully implemented, tested and works fine.
* TODO: this method is in the plan to be added.
* NOT TESTED: this method added and expected to work fine but never tested.
* NOT WORK (x): this method added but not work. x= Description of the error.
--------------------------------------------
Method name | Status
-------------------------|------------------
LogIn | OK
LogOut | OK
NoOperation | OK
SearchSubtitles | OK
DownloadSubtitles | OK
SearchToMail | OK
TryUploadSubtitles | OK
UploadSubtitles | OK
SearchMoviesOnIMDB | OK
GetIMDBMovieDetails | OK
InsertMovie | OK
InsertMovieHash | OK
ServerInfo | OK
ReportWrongMovieHash | OK
ReportWrongImdbMovie | OK
SubtitlesVote | OK
AddComment | OK
AddRequest | OK
GetComments | OK
GetSubLanguages | OK
DetectLanguage | OK
GetAvailableTranslations | OK
GetTranslation | NOT WORK (Returns status of error 410 'Other or unknown error')
AutoUpdate | NOT WORK (Returns status: 'parse error. not well formed')
CheckMovieHash | OK
CheckMovieHash2 | OK
CheckSubHash | OK
--------------------------------------------

View File

@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OpenSubtitlesHandler
{
public class MovieHasher
{
public static byte[] ComputeMovieHash(string filename)
{
byte[] result;
using (Stream input = File.OpenRead(filename))
{
result = ComputeMovieHash(input);
}
return result;
}
private static byte[] ComputeMovieHash(Stream input)
{
long lhash, streamsize;
streamsize = input.Length;
lhash = streamsize;
long i = 0;
byte[] buffer = new byte[sizeof(long)];
while (i < 65536 / sizeof(long) && (input.Read(buffer, 0, sizeof(long)) > 0))
{
i++;
lhash += BitConverter.ToInt64(buffer, 0);
}
input.Position = Math.Max(0, streamsize - 65536);
i = 0;
while (i < 65536 / sizeof(long) && (input.Read(buffer, 0, sizeof(long)) > 0))
{
i++;
lhash += BitConverter.ToInt64(buffer, 0);
}
input.Close();
byte[] result = BitConverter.GetBytes(lhash);
Array.Reverse(result);
return result;
}
public static string ToHexadecimal(byte[] bytes)
{
StringBuilder hexBuilder = new StringBuilder();
for (int i = 0; i < bytes.Length; i++)
{
hexBuilder.Append(bytes[i].ToString("x2"));
}
return hexBuilder.ToString();
}
}
}

View File

@ -0,0 +1,42 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace OpenSubtitlesHandler
{
public struct CheckMovieHash2Data
{
private string _MovieHash;
private string _MovieImdbID;
private string _MovieName;
private string _MovieYear;
private string _MovieKind;
private string _SeriesSeason;
private string _SeriesEpisode;
private string _SeenCount;
public string MovieHash { get { return _MovieHash; } set { _MovieHash = value; } }
public string MovieImdbID { get { return _MovieImdbID; } set { _MovieImdbID = value; } }
public string MovieName { get { return _MovieName; } set { _MovieName = value; } }
public string MovieYear { get { return _MovieYear; } set { _MovieYear = value; } }
public string MovieKind { get { return _MovieKind; } set { _MovieKind = value; } }
public string SeriesSeason { get { return _SeriesSeason; } set { _SeriesSeason = value; } }
public string SeriesEpisode { get { return _SeriesEpisode; } set { _SeriesEpisode = value; } }
public string SeenCount { get { return _SeenCount; } set { _SeenCount = value; } }
}
}

View File

@ -0,0 +1,37 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
namespace OpenSubtitlesHandler
{
public class CheckMovieHash2Result
{
private string name;
private List<CheckMovieHash2Data> data = new List<CheckMovieHash2Data>();
public string Name { get { return name; } set { name = value; } }
public List<CheckMovieHash2Data> Items { get { return data; } set { data = value; } }
public override string ToString()
{
return name;
}
}
}

View File

@ -0,0 +1,42 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
namespace OpenSubtitlesHandler
{
public struct CheckMovieHashResult
{
private string name;
private string _MovieHash;
private string _MovieImdbID;
private string _MovieName;
private string _MovieYear;
public string MovieHash { get { return _MovieHash; } set { _MovieHash = value; } }
public string MovieImdbID { get { return _MovieImdbID; } set { _MovieImdbID = value; } }
public string MovieName { get { return _MovieName; } set { _MovieName = value; } }
public string MovieYear { get { return _MovieYear; } set { _MovieYear = value; } }
public string Name { get { return name; } set { name = value; } }
public override string ToString()
{
return name;
}
}
}

View File

@ -0,0 +1,38 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace OpenSubtitlesHandler
{
public class InsertMovieHashParameters
{
private string _moviehash = "";
private string _moviebytesize = "";
private string _imdbid = "";
private string _movietimems = "";
private string _moviefps = "";
private string _moviefilename = "";
public string moviehash { get { return _moviehash; } set { _moviehash = value; } }
public string moviebytesize { get { return _moviebytesize; } set { _moviebytesize = value; } }
public string imdbid { get { return _imdbid; } set { _imdbid = value; } }
public string movietimems { get { return _movietimems; } set { _movietimems = value; } }
public string moviefps { get { return _moviefps; } set { _moviefps = value; } }
public string moviefilename { get { return _moviefilename; } set { _moviefilename = value; } }
}
}

View File

@ -0,0 +1,41 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
namespace OpenSubtitlesHandler
{
public struct MovieSearchResult
{
private string id;
private string title;
public string ID
{ get { return id; } set { id = value; } }
public string Title
{ get { return title; } set { title = value; } }
/// <summary>
/// Title
/// </summary>
/// <returns></returns>
public override string ToString()
{
return title;
}
}
}

View File

@ -0,0 +1,30 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace OpenSubtitlesHandler
{
public struct SearchToMailMovieParameter
{
private string _moviehash;
private double _moviesize;
public string moviehash { get { return _moviehash; } set { _moviehash = value; } }
public double moviesize { get { return _moviesize; } set { _moviesize = value; } }
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{4A4402D4-E910-443B-B8FC-2C18286A2CA0}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OpenSubtitlesHandler</RootNamespace>
<AssemblyName>OpenSubtitlesHandler</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Console\OSHConsole.cs" />
<Compile Include="Interfaces\IMethodResponse.cs" />
<Compile Include="Interfaces\MethodResponseAttr.cs" />
<Compile Include="Languages\DetectLanguageResult.cs" />
<Compile Include="MethodResponses\MethodResponseAddComment.cs" />
<Compile Include="MethodResponses\MethodResponseAddRequest.cs" />
<Compile Include="MethodResponses\MethodResponseAutoUpdate.cs" />
<Compile Include="MethodResponses\MethodResponseCheckMovieHash.cs" />
<Compile Include="MethodResponses\MethodResponseCheckMovieHash2.cs" />
<Compile Include="MethodResponses\MethodResponseCheckSubHash.cs" />
<Compile Include="MethodResponses\MethodResponseDetectLanguage.cs" />
<Compile Include="MethodResponses\MethodResponseError.cs" />
<Compile Include="MethodResponses\MethodResponseGetAvailableTranslations.cs" />
<Compile Include="MethodResponses\MethodResponseGetComments.cs" />
<Compile Include="MethodResponses\MethodResponseGetSubLanguages.cs" />
<Compile Include="MethodResponses\MethodResponseGetTranslation.cs" />
<Compile Include="MethodResponses\MethodResponseInsertMovie.cs" />
<Compile Include="MethodResponses\MethodResponseInsertMovieHash.cs" />
<Compile Include="MethodResponses\MethodResponseLogIn.cs" />
<Compile Include="MethodResponses\MethodResponseMovieDetails.cs" />
<Compile Include="MethodResponses\MethodResponseMovieSearch.cs" />
<Compile Include="MethodResponses\MethodResponseNoOperation.cs" />
<Compile Include="MethodResponses\MethodResponseReportWrongImdbMovie.cs" />
<Compile Include="MethodResponses\MethodResponseReportWrongMovieHash.cs" />
<Compile Include="MethodResponses\MethodResponseSearchToMail.cs" />
<Compile Include="MethodResponses\MethodResponseServerInfo.cs" />
<Compile Include="MethodResponses\MethodResponseSubtitleDownload.cs" />
<Compile Include="MethodResponses\MethodResponseSubtitleSearch.cs" />
<Compile Include="MethodResponses\MethodResponseSubtitlesVote.cs" />
<Compile Include="MethodResponses\MethodResponseTryUploadSubtitles.cs" />
<Compile Include="MethodResponses\MethodResponseUploadSubtitles.cs" />
<Compile Include="MovieHasher.cs" />
<Compile Include="Movies\CheckMovieHash2Data.cs" />
<Compile Include="Movies\CheckMovieHash2Result.cs" />
<Compile Include="Movies\CheckMovieHashResult.cs" />
<Compile Include="Movies\InsertMovieHashParameters.cs" />
<Compile Include="Movies\MovieSearchResult.cs" />
<Compile Include="Movies\SearchToMailMovieParameter.cs" />
<Compile Include="OpenSubtitles.cs" />
<Compile Include="OtherTypes\GetAvailableTranslationsResult.cs" />
<Compile Include="OtherTypes\GetCommentsResult.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SubtitleTypes\CheckSubHashResult.cs" />
<Compile Include="SubtitleTypes\SubtitleDownloadResult.cs" />
<Compile Include="SubtitleTypes\SubtitleLanguage.cs" />
<Compile Include="SubtitleTypes\SubtitleSearchParameters.cs" />
<Compile Include="SubtitleTypes\SubtitleSearchResult.cs" />
<Compile Include="SubtitleTypes\TryUploadSubtitlesParameters.cs" />
<Compile Include="SubtitleTypes\UploadSubtitleInfoParameter.cs" />
<Compile Include="SubtitleTypes\UploadSubtitleParameters.cs" />
<Compile Include="Utilities.cs" />
<Compile Include="XML-RPC\Enums\XmlRpcValueType.cs" />
<Compile Include="XML-RPC\Types\XmlRpcMethodCall.cs" />
<Compile Include="XML-RPC\Values\IXmlRpcValue.cs" />
<Compile Include="XML-RPC\Values\XmlRpcStructMember.cs" />
<Compile Include="XML-RPC\Values\XmlRpcValueArray.cs" />
<Compile Include="XML-RPC\Values\XmlRpcValueBasic.cs" />
<Compile Include="XML-RPC\Values\XmlRpcValueStruct.cs" />
<Compile Include="XML-RPC\XmlRpcGenerator.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MediaBrowser.Common\MediaBrowser.Common.csproj">
<Project>{9142eefa-7570-41e1-bfcc-468bb571af2f}</Project>
<Name>MediaBrowser.Common</Name>
</ProjectReference>
<ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj">
<Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project>
<Name>MediaBrowser.Model</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="XML-RPC\Docs\XML-RPC.txt" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,39 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace OpenSubtitlesHandler
{
public struct GetAvailableTranslationsResult
{
private string _language;
private string _LastCreated;
private string _StringsNo;
public string LanguageID { get { return _language; } set { _language = value; } }
public string LastCreated { get { return _LastCreated; } set { _LastCreated = value; } }
public string StringsNo { get { return _StringsNo; } set { _StringsNo = value; } }
/// <summary>
/// LanguageID (LastCreated)
/// </summary>
/// <returns></returns>
public override string ToString()
{
return _language + " (" + _LastCreated + ")";
}
}
}

View File

@ -0,0 +1,37 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
namespace OpenSubtitlesHandler
{
public struct GetCommentsResult
{
private string _IDSubtitle;
private string _UserID;
private string _UserNickName;
private string _Comment;
private string _Created;
public string IDSubtitle { get { return _IDSubtitle; } set { _IDSubtitle = value; } }
public string UserID { get { return _UserID; } set { _UserID = value; } }
public string UserNickName { get { return _UserNickName; } set { _UserNickName = value; } }
public string Comment { get { return _Comment; } set { _Comment = value; } }
public string Created { get { return _Created; } set { _Created = value; } }
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OpenSubtitlesHandler")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OpenSubtitlesHandler")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("7c43bda2-2037-449d-8aac-9c0ccee8191f")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,20 @@
OpenSubtitlesHandler
====================
This project is for OpenSubtitles.org integration. The point is to allow user to access OpenSubtitles.org database directly
within ASM without the need to open internet browser.
The plan: Implement the "OSDb protocol" http://trac.opensubtitles.org/projects/opensubtitles/wiki/OSDb
Copyright:
=========
This library ann all its content are written by Ala Ibrahim Hadid.
Copyright © Ala Ibrahim Hadid 2013
mailto:ahdsoftwares@hotmail.com
Resources:
==========
* GetHash.dll: this dll is used to compute hash for movie.
For more information please visit http://trac.opensubtitles.org/projects/opensubtitles/wiki/HashSourceCodes#C2
XML_RPC:
========
This class is created to generate XML-RPC requests as XML String. All you need is to call XML_RPC.Generate() method.

View File

@ -0,0 +1,31 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
namespace OpenSubtitlesHandler
{
public struct CheckSubHashResult
{
private string _hash;
private string _id;
public string Hash { get { return _hash; } set { _hash = value; } }
public string SubID { get { return _id; } set { _id = value; } }
}
}

View File

@ -0,0 +1,44 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
namespace OpenSubtitlesHandler
{
public struct SubtitleDownloadResult
{
private string idsubtitlefile;
private string data;
public string IdSubtitleFile
{ get { return idsubtitlefile; } set { idsubtitlefile = value; } }
/// <summary>
/// Get or set the data of subtitle file. To decode, decode the string to base64 and then decompress with GZIP.
/// </summary>
public string Data
{ get { return data; } set { data = value; } }
/// <summary>
/// IdSubtitleFile
/// </summary>
/// <returns></returns>
public override string ToString()
{
return idsubtitlefile.ToString();
}
}
}

View File

@ -0,0 +1,39 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace OpenSubtitlesHandler
{
public struct SubtitleLanguage
{
private string _SubLanguageID;
private string _LanguageName;
private string _ISO639;
public string SubLanguageID { get { return _SubLanguageID; } set { _SubLanguageID = value; } }
public string LanguageName { get { return _LanguageName; } set { _LanguageName = value; } }
public string ISO639 { get { return _ISO639; } set { _ISO639 = value; } }
/// <summary>
/// LanguageName [SubLanguageID]
/// </summary>
/// <returns>LanguageName [SubLanguageID]</returns>
public override string ToString()
{
return _LanguageName + " [" + _SubLanguageID + "]";
}
}
}

View File

@ -0,0 +1,115 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
namespace OpenSubtitlesHandler
{
/// <summary>
/// Paramaters for subtitle search call
/// </summary>
public struct SubtitleSearchParameters
{
/// <summary>
/// Paramaters for subtitle search call
/// </summary>
/// <param name="subLanguageId">List of language ISO639-3 language codes to search for, divided by ',' (e.g. 'cze,eng,slo')</param>
/// <param name="movieHash">Video file hash as calculated by one of the implementation functions as seen on http://trac.opensubtitles.org/projects/opensubtitles/wiki/HashSourceCodes</param>
/// <param name="movieByteSize">Size of video file in bytes </param>
public SubtitleSearchParameters(string subLanguageId, string movieHash, long movieByteSize)
{
this.subLanguageId = subLanguageId;
this.movieHash = movieHash;
this.movieByteSize = movieByteSize;
this.imdbid = "";
this._episode = "";
this._season = "";
this._query = "";
}
public SubtitleSearchParameters(string subLanguageId, string query, string season, string episode)
{
this.subLanguageId = subLanguageId;
this.movieHash = "";
this.movieByteSize = 0;
this.imdbid = "";
this._episode = episode;
this._season = season;
this._query = query;
}
/// <summary>
/// Paramaters for subtitle search call
/// </summary>
/// <param name="subLanguageId">List of language ISO639-3 language codes to search for, divided by ',' (e.g. 'cze,eng,slo')</param>
/// <param name="movieHash">Video file hash as calculated by one of the implementation functions as seen on http://trac.opensubtitles.org/projects/opensubtitles/wiki/HashSourceCodes</param>
/// <param name="movieByteSize">Size of video file in bytes </param>
/// <param name="imdbid"> IMDb ID of movie this video is part of, belongs to.</param>
public SubtitleSearchParameters(string subLanguageId, string movieHash, long movieByteSize, string imdbid)
{
this.subLanguageId = subLanguageId;
this.movieHash = movieHash;
this.movieByteSize = movieByteSize;
this.imdbid = imdbid;
this._episode = "";
this._season = "";
this._query = "";
}
private string subLanguageId;
private string movieHash;
private long movieByteSize;
private string imdbid;
private string _query;
private string _episode;
public string Episode {
get { return _episode; }
set { _episode = value; }
}
public string Season {
get { return _season; }
set { _season = value; }
}
private string _season;
public string Query {
get { return _query; }
set { _query = value; }
}
/// <summary>
/// List of language ISO639-3 language codes to search for, divided by ',' (e.g. 'cze,eng,slo')
/// </summary>
public string SubLangaugeID { get { return subLanguageId; } set { subLanguageId = value; } }
/// <summary>
/// Video file hash as calculated by one of the implementation functions as seen on http://trac.opensubtitles.org/projects/opensubtitles/wiki/HashSourceCodes
/// </summary>
public string MovieHash { get { return movieHash; } set { movieHash = value; } }
/// <summary>
/// Size of video file in bytes
/// </summary>
public long MovieByteSize { get { return movieByteSize; } set { movieByteSize = value; } }
/// <summary>
/// IMDb ID of movie this video is part of, belongs to.
/// </summary>
public string IMDbID { get { return imdbid; } set { imdbid = value; } }
}
}

View File

@ -0,0 +1,137 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
namespace OpenSubtitlesHandler
{
/// <summary>
/// The subtitle search result that comes with server response on SearchSubtitles successed call
/// </summary>
public struct SubtitleSearchResult
{
private string _IDSubMovieFile;
private string _MovieHash;
private string _MovieByteSize;
private string _MovieTimeMS;
private string _IDSubtitleFile;
private string _SubFileName;
private string _SubActualCD;
private string _SubSize;
private string _SubHash;
private string _IDSubtitle;
private string _UserID;
private string _SubLanguageID;
private string _SubFormat;
private string _SeriesSeason;
private string _SeriesEpisode;
private string _SubSumCD;
private string _SubAuthorComment;
private string _SubAddDate;
private string _SubBad;
private string _SubRating;
private string _SubDownloadsCnt;
private string _MovieReleaseName;
private string _IDMovie;
private string _IDMovieImdb;
private string _MovieName;
private string _MovieNameEng;
private string _MovieYear;
private string _MovieImdbRating;
private string _UserNickName;
private string _ISO639;
private string _LanguageName;
private string _SubDownloadLink;
private string _ZipDownloadLink;
public string IDSubMovieFile
{ get { return _IDSubMovieFile; } set { _IDSubMovieFile = value; } }
public string MovieHash
{ get { return _MovieHash; } set { _MovieHash = value; } }
public string MovieByteSize
{ get { return _MovieByteSize; } set { _MovieByteSize = value; } }
public string MovieTimeMS
{ get { return _MovieTimeMS; } set { _MovieTimeMS = value; } }
public string IDSubtitleFile
{ get { return _IDSubtitleFile; } set { _IDSubtitleFile = value; } }
public string SubFileName
{ get { return _SubFileName; } set { _SubFileName = value; } }
public string SubActualCD
{ get { return _SubActualCD; } set { _SubActualCD = value; } }
public string SubSize
{ get { return _SubSize; } set { _SubSize = value; } }
public string SubHash
{ get { return _SubHash; } set { _SubHash = value; } }
public string IDSubtitle
{ get { return _IDSubtitle; } set { _IDSubtitle = value; } }
public string UserID
{ get { return _UserID; } set { _UserID = value; } }
public string SubLanguageID
{ get { return _SubLanguageID; } set { _SubLanguageID = value; } }
public string SubFormat
{ get { return _SubFormat; } set { _SubFormat = value; } }
public string SubSumCD
{ get { return _SubSumCD; } set { _SubSumCD = value; } }
public string SubAuthorComment
{ get { return _SubAuthorComment; } set { _SubAuthorComment = value; } }
public string SubAddDate
{ get { return _SubAddDate; } set { _SubAddDate = value; } }
public string SubBad
{ get { return _SubBad; } set { _SubBad = value; } }
public string SubRating
{ get { return _SubRating; } set { _SubRating = value; } }
public string SubDownloadsCnt
{ get { return _SubDownloadsCnt; } set { _SubDownloadsCnt = value; } }
public string MovieReleaseName
{ get { return _MovieReleaseName; } set { _MovieReleaseName = value; } }
public string IDMovie
{ get { return _IDMovie; } set { _IDMovie = value; } }
public string IDMovieImdb
{ get { return _IDMovieImdb; } set { _IDMovieImdb = value; } }
public string MovieName
{ get { return _MovieName; } set { _MovieName = value; } }
public string MovieNameEng
{ get { return _MovieNameEng; } set { _MovieNameEng = value; } }
public string MovieYear
{ get { return _MovieYear; } set { _MovieYear = value; } }
public string MovieImdbRating
{ get { return _MovieImdbRating; } set { _MovieImdbRating = value; } }
public string UserNickName
{ get { return _UserNickName; } set { _UserNickName = value; } }
public string ISO639
{ get { return _ISO639; } set { _ISO639 = value; } }
public string LanguageName
{ get { return _LanguageName; } set { _LanguageName = value; } }
public string SubDownloadLink
{ get { return _SubDownloadLink; } set { _SubDownloadLink = value; } }
public string ZipDownloadLink
{ get { return _ZipDownloadLink; } set { _ZipDownloadLink = value; } }
public string SeriesSeason
{ get { return _SeriesSeason; } set { _SeriesSeason = value; } }
public string SeriesEpisode
{ get { return _SeriesEpisode; } set { _SeriesEpisode = value; } }
/// <summary>
/// SubFileName + " (" + SubFormat + ")"
/// </summary>
/// <returns></returns>
public override string ToString()
{
return _SubFileName + " (" + _SubFormat + ")";
}
}
}

View File

@ -0,0 +1,48 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
namespace OpenSubtitlesHandler
{
public class TryUploadSubtitlesParameters
{
private string _subhash = "";
private string _subfilename = "";
private string _moviehash = "";
private string _moviebytesize = "";
private int _movietimems = 0;
private int _movieframes = 0;
private double _moviefps = 0;
private string _moviefilename = "";
public string subhash { get { return _subhash; } set { _subhash = value; } }
public string subfilename { get { return _subfilename; } set { _subfilename = value; } }
public string moviehash { get { return _moviehash; } set { _moviehash = value; } }
public string moviebytesize { get { return _moviebytesize; } set { _moviebytesize = value; } }
public int movietimems { get { return _movietimems; } set { _movietimems = value; } }
public int movieframes { get { return _movieframes; } set { _movieframes = value; } }
public double moviefps { get { return _moviefps; } set { _moviefps = value; } }
public string moviefilename { get { return _moviefilename; } set { _moviefilename = value; } }
public override string ToString()
{
return _subfilename + " (" + _subhash + ")";
}
}
}

View File

@ -0,0 +1,46 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
namespace OpenSubtitlesHandler
{
public class UploadSubtitleInfoParameters
{
private string _idmovieimdb;
private string _moviereleasename;
private string _movieaka;
private string _sublanguageid;
private string _subauthorcomment;
private bool _hearingimpaired;
private bool _highdefinition;
private bool _automatictranslation;
private List<UploadSubtitleParameters> cds;
public string idmovieimdb { get { return _idmovieimdb; } set { _idmovieimdb = value; } }
public string moviereleasename { get { return _moviereleasename; } set { _moviereleasename = value; } }
public string movieaka { get { return _movieaka; } set { _movieaka = value; } }
public string sublanguageid { get { return _sublanguageid; } set { _sublanguageid = value; } }
public string subauthorcomment { get { return _subauthorcomment; } set { _subauthorcomment = value; } }
public bool hearingimpaired { get { return _hearingimpaired; } set { _hearingimpaired = value; } }
public bool highdefinition { get { return _highdefinition; } set { _highdefinition = value; } }
public bool automatictranslation { get { return _automatictranslation; } set { _automatictranslation = value; } }
public List<UploadSubtitleParameters> CDS { get { return cds; } set { cds = value; } }
}
}

View File

@ -0,0 +1,53 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
namespace OpenSubtitlesHandler
{
public struct UploadSubtitleParameters
{
private string _subhash;
private string _subfilename;
private string _moviehash;
private double _moviebytesize;
private int _movietimems;
private int _movieframes;
private double _moviefps;
private string _moviefilename;
private string _subcontent;
public string subhash { get { return _subhash; } set { _subhash = value; } }
public string subfilename { get { return _subfilename; } set { _subfilename = value; } }
public string moviehash { get { return _moviehash; } set { _moviehash = value; } }
public double moviebytesize { get { return _moviebytesize; } set { _moviebytesize = value; } }
public int movietimems { get { return _movietimems; } set { _movietimems = value; } }
public int movieframes { get { return _movieframes; } set { _movieframes = value; } }
public double moviefps { get { return _moviefps; } set { _moviefps = value; } }
public string moviefilename { get { return _moviefilename; } set { _moviefilename = value; } }
/// <summary>
/// Sub content. Note: this value must be the subtitle file gziped and then base64 decoded.
/// </summary>
public string subcontent { get { return _subcontent; } set { _subcontent = value; } }
public override string ToString()
{
return _subfilename + " (" + _subhash + ")";
}
}
}

View File

@ -0,0 +1,235 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.IO.Compression;
using System.Net;
using System.Security.Cryptography;
using System.Threading.Tasks;
using MediaBrowser.Common.Net;
namespace OpenSubtitlesHandler
{
/// <summary>
/// Include helper methods. All member are statics.
/// </summary>
public sealed class Utilities
{
private const string XML_RPC_SERVER = "http://api.opensubtitles.org/xml-rpc";
/// <summary>
/// Compute movie hash
/// </summary>
/// <param name="fileName">The complete media file path</param>
/// <returns>The hash as Hexadecimal string</returns>
public static string ComputeHash(string fileName)
{
byte[] hash = MovieHasher.ComputeMovieHash(fileName);
return MovieHasher.ToHexadecimal(hash);
}
/// <summary>
/// Compute md5 for a file
/// </summary>
/// <param name="filename">The complete file path</param>
/// <returns>MD5 of the file</returns>
public static string ComputeMd5(string filename)
{
var md5 = MD5.Create();
var sb = new StringBuilder();
Stream str = new FileStream(filename, FileMode.Open, FileAccess.Read);
foreach (var b in md5.ComputeHash(str))
sb.Append(b.ToString("x2").ToLower());
str.Close();
return sb.ToString();
}
/// <summary>
/// Decompress data using GZip
/// </summary>
/// <param name="dataToDecompress">The stream that hold the data</param>
/// <returns>Bytes array of decompressed data</returns>
public static byte[] Decompress(Stream dataToDecompress)
{
MemoryStream target = new MemoryStream();
using (System.IO.Compression.GZipStream decompressionStream = new System.IO.Compression.GZipStream(dataToDecompress,
System.IO.Compression.CompressionMode.Decompress))
{
decompressionStream.CopyTo(target);
}
return target.GetBuffer();
}
/// <summary>
/// Compress data using GZip (the retunred buffer will be WITHOUT HEADER)
/// </summary>
/// <param name="dataToCompress">The stream that hold the data</param>
/// <returns>Bytes array of compressed data WITHOUT HEADER bytes</returns>
public static byte[] Compress(Stream dataToCompress)
{
/*using (var compressed = new MemoryStream())
{
using (var compressor = new System.IO.Compression.GZipStream(compressed,
System.IO.Compression.CompressionMode.Compress))
{
dataToCompress.CopyTo(compressor);
}
// Get the compressed bytes only after closing the GZipStream
return compressed.ToArray();
}*/
//using (var compressedOutput = new MemoryStream())
//{
// using (var compressedStream = new ZlibStream(compressedOutput,
// Ionic.Zlib.CompressionMode.Compress,
// CompressionLevel.Default, false))
// {
// var buffer = new byte[4096];
// int byteCount;
// do
// {
// byteCount = dataToCompress.Read(buffer, 0, buffer.Length);
// if (byteCount > 0)
// {
// compressedStream.Write(buffer, 0, byteCount);
// }
// } while (byteCount > 0);
// }
// return compressedOutput.ToArray();
//}
throw new NotImplementedException();
}
/// <summary>
/// Handle server response stream and decode it as given encoding string.
/// </summary>
/// <param name="responseStream">The response stream. Expects a stream that doesn't support seek.</param>
/// <param name="encoding">The encoding that should be used to decode buffer</param>
/// <returns>The string of the stream after decode using given encoding</returns>
public static string GetStreamString(Stream responseStream, Encoding encoding)
{
// Handle response, should be XML text.
List<byte> data = new List<byte>();
while (true)
{
int r = responseStream.ReadByte();
if (r < 0)
break;
data.Add((byte)r);
}
responseStream.Close();
return encoding.GetString(data.ToArray());
}
/// <summary>
/// Handle server response stream and decode it as ASCII encoding string.
/// </summary>
/// <param name="responseStream">The response stream. Expects a stream that doesn't support seek.</param>
/// <returns>The string of the stream after decode using ASCII encoding</returns>
public static string GetStreamString(Stream responseStream)
{
return GetStreamString(responseStream, Encoding.ASCII);
}
public static IHttpClient HttpClient { get; set; }
/// <summary>
/// Send a request to the server
/// </summary>
/// <param name="request">The request buffer to send as bytes array.</param>
/// <param name="userAgent">The user agent value.</param>
/// <returns>Response of the server or stream of error message as string started with 'ERROR:' keyword.</returns>
public static Stream SendRequest(byte[] request, string userAgent)
{
return SendRequestAsync(request, userAgent).Result;
//HttpWebRequest req = (HttpWebRequest)WebRequest.Create(XML_RPC_SERVER);
//req.ContentType = "text/xml";
//req.Host = "api.opensubtitles.org:80";
//req.Method = "POST";
//req.UserAgent = "xmlrpc-epi-php/0.2 (PHP)";
//req.ContentLength = request.Length;
//ServicePointManager.Expect100Continue = false;
//try
//{
// using (Stream stm = req.GetRequestStream())
// {
// stm.Write(request, 0, request.Length);
// }
// WebResponse response = req.GetResponse();
// return response.GetResponseStream();
//}
//catch (Exception ex)
//{
// Stream errorStream = new MemoryStream();
// byte[] dd = Encoding.ASCII.GetBytes("ERROR: " + ex.Message);
// errorStream.Write(dd, 0, dd.Length);
// errorStream.Position = 0;
// return errorStream;
//}
}
public static async Task<Stream> SendRequestAsync(byte[] request, string userAgent)
{
var options = new HttpRequestOptions
{
RequestContentBytes = request,
RequestContentType = "text/xml",
UserAgent = "xmlrpc-epi-php/0.2 (PHP)",
Url = XML_RPC_SERVER
};
var result = await HttpClient.Post(options).ConfigureAwait(false);
return result.Content;
//HttpWebRequest req = (HttpWebRequest)WebRequest.Create(XML_RPC_SERVER);
//req.ContentType = "text/xml";
//req.Host = "api.opensubtitles.org:80";
//req.Method = "POST";
//req.UserAgent = "xmlrpc-epi-php/0.2 (PHP)";
//req.ContentLength = request.Length;
//ServicePointManager.Expect100Continue = false;
//try
//{
// using (Stream stm = req.GetRequestStream())
// {
// stm.Write(request, 0, request.Length);
// }
// WebResponse response = req.GetResponse();
// return response.GetResponseStream();
//}
//catch (Exception ex)
//{
// Stream errorStream = new MemoryStream();
// byte[] dd = Encoding.ASCII.GetBytes("ERROR: " + ex.Message);
// errorStream.Write(dd, 0, dd.Length);
// errorStream.Position = 0;
// return errorStream;
//}
}
}
}

View File

@ -0,0 +1,225 @@
XML-RPC Specification
Tue, Jun 15, 1999; by Dave Winer.
Updated 6/30/03 DW
Updated 10/16/99 DW
Updated 1/21/99 DW
This specification documents the XML-RPC protocol implemented in UserLand Frontier 5.1.
For a non-technical explanation, see XML-RPC for Newbies.
This page provides all the information that an implementor needs.
Overview
XML-RPC is a Remote Procedure Calling protocol that works over the Internet.
An XML-RPC message is an HTTP-POST request. The body of the request is in XML. A procedure executes on the server and the value it returns is also formatted in XML.
Procedure parameters can be scalars, numbers, strings, dates, etc.; and can also be complex record and list structures.
Request example
Here's an example of an XML-RPC request:
POST /RPC2 HTTP/1.0
User-Agent: Frontier/5.1.2 (WinNT)
Host: betty.userland.com
Content-Type: text/xml
Content-length: 181
<?xml version="1.0"?>
<methodCall>
<methodName>examples.getStateName</methodName>
<params>
<param>
<value>
<i4>41</i4>
</value>
</param>
</params>
</methodCall>
Header requirements
The format of the URI in the first line of the header is not specified. For example, it could be empty, a single slash, if the server is only handling XML-RPC calls. However, if the server is handling a mix of incoming HTTP requests, we allow the URI to help route the request to the code that handles XML-RPC requests. (In the example, the URI is /RPC2, telling the server to route the request to the "RPC2" responder.)
A User-Agent and Host must be specified.
The Content-Type is text/xml.
The Content-Length must be specified and must be correct.
Payload format
The payload is in XML, a single <methodCall> structure.
The <methodCall> must contain a <methodName> sub-item, a string, containing the name of the method to be called. The string may only contain identifier characters, upper and lower-case A-Z, the numeric characters, 0-9, underscore, dot, colon and slash. It's entirely up to the server to decide how to interpret the characters in a methodName.
For example, the methodName could be the name of a file containing a script that executes on an incoming request. It could be the name of a cell in a database table. Or it could be a path to a file contained within a hierarchy of folders and files.
If the procedure call has parameters, the <methodCall> must contain a <params> sub-item. The <params> sub-item can contain any number of <param>s, each of which has a <value>.
Scalar <value>s
<value>s can be scalars, type is indicated by nesting the value inside one of the tags listed in this table:
Tag Type Example
<i4> or <int> four-byte signed integer -12
<boolean> 0 (false) or 1 (true) 1
<string> string hello world
<double> double-precision signed floating point number -12.214
<dateTime.iso8601> date/time 19980717T14:08:55
<base64> base64-encoded binary eW91IGNhbid0IHJlYWQgdGhpcyE=
If no type is indicated, the type is string.
<struct>s
A value can also be of type <struct>.
A <struct> contains <member>s and each <member> contains a <name> and a <value>.
Here's an example of a two-element <struct>:
<struct>
<member>
<name>lowerBound</name>
<value><i4>18</i4></value>
</member>
<member>
<name>upperBound</name>
<value><i4>139</i4></value>
</member>
</struct>
<struct>s can be recursive, any <value> may contain a <struct> or any other type, including an <array>, described below.
<array>s
A value can also be of type <array>.
An <array> contains a single <data> element, which can contain any number of <value>s.
Here's an example of a four-element array:
<array>
<data>
<value><i4>12</i4></value>
<value><string>Egypt</string></value>
<value><boolean>0</boolean></value>
<value><i4>-31</i4></value>
</data>
</array>
<array> elements do not have names.
You can mix types as the example above illustrates.
<arrays>s can be recursive, any value may contain an <array> or any other type, including a <struct>, described above.
Response example
Here's an example of a response to an XML-RPC request:
HTTP/1.1 200 OK
Connection: close
Content-Length: 158
Content-Type: text/xml
Date: Fri, 17 Jul 1998 19:55:08 GMT
Server: UserLand Frontier/5.1.2-WinNT
<?xml version="1.0"?> <methodResponse> <params> <param> <value><string>South Dakota</string></value> </param> </params> </methodResponse>
Response format
Unless there's a lower-level error, always return 200 OK.
The Content-Type is text/xml. Content-Length must be present and correct.
The body of the response is a single XML structure, a <methodResponse>, which can contain a single <params> which contains a single <param> which contains a single <value>.
The <methodResponse> could also contain a <fault> which contains a <value> which is a <struct> containing two elements, one named <faultCode>, an <int> and one named <faultString>, a <string>.
A <methodResponse> can not contain both a <fault> and a <params>.
Fault example
HTTP/1.1 200 OK
Connection: close
Content-Length: 426
Content-Type: text/xml
Date: Fri, 17 Jul 1998 19:55:02 GMT
Server: UserLand Frontier/5.1.2-WinNT
<?xml version="1.0"?> <methodResponse> <fault> <value> <struct> <member> <name>faultCode</name> <value><int>4</int></value> </member> <member> <name>faultString</name> <value><string>Too many parameters.</string></value> </member> </struct> </value> </fault> </methodResponse>
Strategies/Goals
Firewalls. The goal of this protocol is to lay a compatible foundation across different environments, no new power is provided beyond the capabilities of the CGI interface. Firewall software can watch for POSTs whose Content-Type is text/xml.
Discoverability. We wanted a clean, extensible format that's very simple. It should be possible for an HTML coder to be able to look at a file containing an XML-RPC procedure call, understand what it's doing, and be able to modify it and have it work on the first or second try.
Easy to implement. We also wanted it to be an easy to implement protocol that could quickly be adapted to run in other environments or on other operating systems.
Updated 1/21/99 DW
The following questions came up on the UserLand discussion group as XML-RPC was being implemented in Python.
The Response Format section says "The body of the response is a single XML structure, a <methodResponse>, which can contain a single <params>..." This is confusing. Can we leave out the <params>?
No you cannot leave it out if the procedure executed successfully. There are only two options, either a response contains a <params> structure or it contains a <fault> structure. That's why we used the word "can" in that sentence.
Is "boolean" a distinct data type, or can boolean values be interchanged with integers (e.g. zero=false, non-zero=true)?
Yes, boolean is a distinct data type. Some languages/environments allow for an easy coercion from zero to false and one to true, but if you mean true, send a boolean type with the value true, so your intent can't possibly be misunderstood.
What is the legal syntax (and range) for integers? How to deal with leading zeros? Is a leading plus sign allowed? How to deal with whitespace?
An integer is a 32-bit signed number. You can include a plus or minus at the beginning of a string of numeric characters. Leading zeros are collapsed. Whitespace is not permitted. Just numeric characters preceeded by a plus or minus.
What is the legal syntax (and range) for floating point values (doubles)? How is the exponent represented? How to deal with whitespace? Can infinity and "not a number" be represented?
There is no representation for infinity or negative infinity or "not a number". At this time, only decimal point notation is allowed, a plus or a minus, followed by any number of numeric characters, followed by a period and any number of numeric characters. Whitespace is not allowed. The range of allowable values is implementation-dependent, is not specified.
What characters are allowed in strings? Non-printable characters? Null characters? Can a "string" be used to hold an arbitrary chunk of binary data?
Any characters are allowed in a string except < and &, which are encoded as &lt; and &amp;. A string can be used to encode binary data.
Does the "struct" element keep the order of keys. Or in other words, is the struct "foo=1, bar=2" equivalent to "bar=2, foo=1" or not?
The struct element does not preserve the order of the keys. The two structs are equivalent.
Can the <fault> struct contain other members than <faultCode> and <faultString>? Is there a global list of faultCodes? (so they can be mapped to distinct exceptions for languages like Python and Java)?
A <fault> struct may not contain members other than those specified. This is true for all other structures. We believe the specification is flexible enough so that all reasonable data-transfer needs can be accomodated within the specified structures. If you believe strongly that this is not true, please post a message on the discussion group.
There is no global list of fault codes. It is up to the server implementer, or higher-level standards to specify fault codes.
What timezone should be assumed for the dateTime.iso8601 type? UTC? localtime?
Don't assume a timezone. It should be specified by the server in its documentation what assumptions it makes about timezones.
Additions
<base64> type. 1/21/99 DW.
Updated 6/30/03 DW
Removed "ASCII" from definition of string.
Changed copyright dates, below, to 1999-2003 from 1998-99.
Copyright and disclaimer
© Copyright 1998-2003 UserLand Software. All Rights Reserved.
This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and these paragraphs are included on all such copies and derivative works.
This document may not be modified in any way, such as by removing the copyright notice or references to UserLand or other organizations. Further, while these copyright restrictions apply to the written XML-RPC specification, no claim of ownership is made by UserLand to the protocol it describes. Any party may, for commercial or non-commercial purposes, implement this protocol without royalty or license fee to UserLand. The limited permissions granted herein are perpetual and will not be revoked by UserLand or its successors or assigns.
This document and the information contained herein is provided on an "AS IS" basis and USERLAND DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.

View File

@ -0,0 +1,25 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace XmlRpcHandler
{
public enum XmlRpcBasicValueType
{
String, Int, Boolean, Double, dateTime_iso8601, base64
}
}

View File

@ -0,0 +1,63 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
namespace XmlRpcHandler
{
/// <summary>
/// A method call
/// </summary>
public struct XmlRpcMethodCall
{
/// <summary>
/// A method call
/// </summary>
/// <param name="name">The name of this method</param>
public XmlRpcMethodCall(string name)
{
this.name = name;
this.parameters = new List<IXmlRpcValue>();
}
/// <summary>
/// A method call
/// </summary>
/// <param name="name">The name of this method</param>
/// <param name="parameters">A list of parameters</param>
public XmlRpcMethodCall(string name, List<IXmlRpcValue> parameters)
{
this.name = name;
this.parameters = parameters;
}
private string name;
private List<IXmlRpcValue> parameters;
/// <summary>
/// Get or set the name of this method
/// </summary>
public string Name
{ get { return name; } set { name = value; } }
/// <summary>
/// Get or set the parameters to be sent
/// </summary>
public List<IXmlRpcValue> Parameters
{ get { return parameters; } set { parameters = value; } }
}
}

View File

@ -0,0 +1,37 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
namespace XmlRpcHandler
{
public abstract class IXmlRpcValue
{
public IXmlRpcValue()
{ }
public IXmlRpcValue(object data)
{
this.data = data;
}
private object data;
/// <summary>
/// Get or set the data of this value
/// </summary>
public virtual object Data { get { return data; } set { data = value; } }
}
}

View File

@ -0,0 +1,44 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
namespace XmlRpcHandler
{
public class XmlRpcStructMember
{
public XmlRpcStructMember(string name, IXmlRpcValue data)
{
this.name = name;
this.data = data;
}
private string name;
private IXmlRpcValue data;
/// <summary>
/// Get or set the name of this member
/// </summary>
public string Name
{ get { return name; } set { name = value; } }
/// <summary>
/// Get or set the data of this member
/// </summary>
public IXmlRpcValue Data
{ get { return data; } set { data = value; } }
}
}

View File

@ -0,0 +1,121 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
namespace XmlRpcHandler
{
public class XmlRpcValueArray : IXmlRpcValue
{
public XmlRpcValueArray() :
base()
{
values = new List<IXmlRpcValue>();
}
public XmlRpcValueArray(object data) :
base(data)
{
values = new List<IXmlRpcValue>();
}
public XmlRpcValueArray(string[] texts) :
base()
{
values = new List<IXmlRpcValue>();
foreach (string val in texts)
{
values.Add(new XmlRpcValueBasic(val));
}
}
public XmlRpcValueArray(int[] ints) :
base()
{
values = new List<IXmlRpcValue>();
foreach (int val in ints)
{
values.Add(new XmlRpcValueBasic(val));
}
}
public XmlRpcValueArray(double[] doubles) :
base()
{
values = new List<IXmlRpcValue>();
foreach (double val in doubles)
{
values.Add(new XmlRpcValueBasic(val));
}
}
public XmlRpcValueArray(bool[] bools) :
base()
{
values = new List<IXmlRpcValue>();
foreach (bool val in bools)
{
values.Add(new XmlRpcValueBasic(val));
}
}
public XmlRpcValueArray(long[] base24s) :
base()
{
values = new List<IXmlRpcValue>();
foreach (long val in base24s)
{
values.Add(new XmlRpcValueBasic(val));
}
}
public XmlRpcValueArray(DateTime[] dates) :
base()
{
values = new List<IXmlRpcValue>();
foreach (DateTime val in dates)
{
values.Add(new XmlRpcValueBasic(val));
}
}
public XmlRpcValueArray(XmlRpcValueBasic[] basicValues) :
base()
{
values = new List<IXmlRpcValue>();
foreach (XmlRpcValueBasic val in basicValues)
{
values.Add(val);
}
}
public XmlRpcValueArray(XmlRpcValueStruct[] structs) :
base()
{
values = new List<IXmlRpcValue>();
foreach (XmlRpcValueStruct val in structs)
{
values.Add(val);
}
}
public XmlRpcValueArray(XmlRpcValueArray[] arrays) :
base()
{
values = new List<IXmlRpcValue>();
foreach (XmlRpcValueArray val in arrays)
{
values.Add(val);
}
}
private List<IXmlRpcValue> values;
public List<IXmlRpcValue> Values { get { return values; } set { values = value; } }
}
}

View File

@ -0,0 +1,100 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
namespace XmlRpcHandler
{
public class XmlRpcValueBasic : IXmlRpcValue
{
public XmlRpcValueBasic()
: base()
{ }
public XmlRpcValueBasic(string data)
: base(data)
{ this.type = XmlRpcBasicValueType.String; }
public XmlRpcValueBasic(int data)
: base(data)
{ this.type = XmlRpcBasicValueType.Int; }
public XmlRpcValueBasic(double data)
: base(data)
{ this.type = XmlRpcBasicValueType.Double; }
public XmlRpcValueBasic(DateTime data)
: base(data)
{ this.type = XmlRpcBasicValueType.dateTime_iso8601; }
public XmlRpcValueBasic(bool data)
: base(data)
{ this.type = XmlRpcBasicValueType.Boolean; }
public XmlRpcValueBasic(long data)
: base(data)
{ this.type = XmlRpcBasicValueType.base64; }
public XmlRpcValueBasic(object data, XmlRpcBasicValueType type)
: base(data)
{ this.type = type; }
private XmlRpcBasicValueType type = XmlRpcBasicValueType.String;
/// <summary>
/// Get or set the type of this basic value
/// </summary>
public XmlRpcBasicValueType ValueType { get { return type; } set { type = value; } }
/*Oprators. help a lot.*/
public static implicit operator string(XmlRpcValueBasic f)
{
if (f.type == XmlRpcBasicValueType.String)
return f.Data.ToString();
else
throw new Exception("Unable to convert, this value is not string type.");
}
public static implicit operator int(XmlRpcValueBasic f)
{
if (f.type == XmlRpcBasicValueType.String)
return (int)f.Data;
else
throw new Exception("Unable to convert, this value is not int type.");
}
public static implicit operator double(XmlRpcValueBasic f)
{
if (f.type == XmlRpcBasicValueType.String)
return (double)f.Data;
else
throw new Exception("Unable to convert, this value is not double type.");
}
public static implicit operator bool(XmlRpcValueBasic f)
{
if (f.type == XmlRpcBasicValueType.String)
return (bool)f.Data;
else
throw new Exception("Unable to convert, this value is not bool type.");
}
public static implicit operator long(XmlRpcValueBasic f)
{
if (f.type == XmlRpcBasicValueType.String)
return (long)f.Data;
else
throw new Exception("Unable to convert, this value is not long type.");
}
public static implicit operator DateTime(XmlRpcValueBasic f)
{
if (f.type == XmlRpcBasicValueType.String)
return (DateTime)f.Data;
else
throw new Exception("Unable to convert, this value is not DateTime type.");
}
}
}

View File

@ -0,0 +1,43 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
namespace XmlRpcHandler
{
/// <summary>
/// Represents XML-RPC struct
/// </summary>
public class XmlRpcValueStruct : IXmlRpcValue
{
/// <summary>
/// Represents XML-RPC struct
/// </summary>
/// <param name="members"></param>
public XmlRpcValueStruct(List<XmlRpcStructMember> members)
{ this.members = members; }
private List<XmlRpcStructMember> members;
/// <summary>
/// Get or set the members collection
/// </summary>
public List<XmlRpcStructMember> Members
{ get { return members; } set { members = value; } }
}
}

View File

@ -0,0 +1,323 @@
/* This file is part of OpenSubtitles Handler
A library that handle OpenSubtitles.org XML-RPC methods.
Copyright © Ala Ibrahim Hadid 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Text;
using System.Collections.Generic;
using System.IO;
using System.Xml;
namespace XmlRpcHandler
{
/// <summary>
/// A class for making XML-RPC requests. The requests then can be sent directly as http request.
/// </summary>
public class XmlRpcGenerator
{
/// <summary>
/// Generate XML-RPC request using method call.
/// </summary>
/// <param name="method">The method call</param>
/// <returns>The request in xml.</returns>
public static byte[] Generate(XmlRpcMethodCall method)
{ return Generate(new XmlRpcMethodCall[] { method }); }
/// <summary>
/// Generate XML-RPC request using method calls array.
/// </summary>
/// <param name="methods">The method calls array</param>
/// <returns>The request in utf8 xml string as buffer</returns>
public static byte[] Generate(XmlRpcMethodCall[] methods)
{
if (methods == null)
throw new Exception("No method to write !");
if (methods.Length == 0)
throw new Exception("No method to write !");
// Create xml
XmlWriterSettings sett = new XmlWriterSettings();
sett.Indent = true;
sett.Encoding = Encoding.UTF8;
FileStream str = new FileStream(Path.GetTempPath() + "\\request.xml", FileMode.Create, FileAccess.Write);
XmlWriter XMLwrt = XmlWriter.Create(str, sett);
// Let's write the methods
foreach (XmlRpcMethodCall method in methods)
{
XMLwrt.WriteStartElement("methodCall");//methodCall
XMLwrt.WriteStartElement("methodName");//methodName
XMLwrt.WriteString(method.Name);
XMLwrt.WriteEndElement();//methodName
XMLwrt.WriteStartElement("params");//params
// Write values
foreach (IXmlRpcValue p in method.Parameters)
{
XMLwrt.WriteStartElement("param");//param
if (p is XmlRpcValueBasic)
{
WriteBasicValue(XMLwrt, (XmlRpcValueBasic)p);
}
else if (p is XmlRpcValueStruct)
{
WriteStructValue(XMLwrt, (XmlRpcValueStruct)p);
}
else if (p is XmlRpcValueArray)
{
WriteArrayValue(XMLwrt, (XmlRpcValueArray)p);
}
XMLwrt.WriteEndElement();//param
}
XMLwrt.WriteEndElement();//params
XMLwrt.WriteEndElement();//methodCall
}
XMLwrt.Flush();
XMLwrt.Close();
str.Close();
string requestContent = File.ReadAllText(Path.GetTempPath() + "\\request.xml");
return Encoding.UTF8.GetBytes(requestContent);
}
/// <summary>
/// Decode response then return the values
/// </summary>
/// <param name="xmlResponse">The response xml string as provided by server as methodResponse</param>
/// <returns></returns>
public static XmlRpcMethodCall[] DecodeMethodResponse(string xmlResponse)
{
List<XmlRpcMethodCall> methods = new List<XmlRpcMethodCall>();
XmlReaderSettings sett = new XmlReaderSettings();
sett.DtdProcessing = DtdProcessing.Ignore;
sett.IgnoreWhitespace = true;
MemoryStream str = new MemoryStream(Encoding.ASCII.GetBytes(xmlResponse));
if (xmlResponse.Contains(@"encoding=""utf-8"""))
{
str = new MemoryStream(Encoding.UTF8.GetBytes(xmlResponse));
}
XmlReader XMLread = XmlReader.Create(str, sett);
XmlRpcMethodCall call = new XmlRpcMethodCall("methodResponse");
// Read parameters
while (XMLread.Read())
{
if (XMLread.Name == "param" && XMLread.IsStartElement())
{
IXmlRpcValue val = ReadValue(XMLread);
if (val != null)
call.Parameters.Add(val);
}
}
methods.Add(call);
XMLread.Close();
return methods.ToArray();
}
private static void WriteBasicValue(XmlWriter XMLwrt, XmlRpcValueBasic val)
{
XMLwrt.WriteStartElement("value");//value
switch (val.ValueType)
{
case XmlRpcBasicValueType.String:
XMLwrt.WriteStartElement("string");
if (val.Data != null)
XMLwrt.WriteString(val.Data.ToString());
XMLwrt.WriteEndElement();
break;
case XmlRpcBasicValueType.Int:
XMLwrt.WriteStartElement("int");
if (val.Data != null)
XMLwrt.WriteString(val.Data.ToString());
XMLwrt.WriteEndElement();
break;
case XmlRpcBasicValueType.Boolean:
XMLwrt.WriteStartElement("boolean");
if (val.Data != null)
XMLwrt.WriteString(((bool)val.Data) ? "1" : "0");
XMLwrt.WriteEndElement();
break;
case XmlRpcBasicValueType.Double:
XMLwrt.WriteStartElement("double");
if (val.Data != null)
XMLwrt.WriteString(val.Data.ToString());
XMLwrt.WriteEndElement();
break;
case XmlRpcBasicValueType.dateTime_iso8601:
XMLwrt.WriteStartElement("dateTime.iso8601");
// Get date time format
if (val.Data != null)
{
DateTime time = (DateTime)val.Data;
string dt = time.Year + time.Month.ToString("D2") + time.Day.ToString("D2") +
"T" + time.Hour.ToString("D2") + ":" + time.Minute.ToString("D2") + ":" +
time.Second.ToString("D2");
XMLwrt.WriteString(dt);
}
XMLwrt.WriteEndElement();
break;
case XmlRpcBasicValueType.base64:
XMLwrt.WriteStartElement("base64");
if (val.Data != null)
XMLwrt.WriteString(Convert.ToBase64String(BitConverter.GetBytes((long)val.Data)));
XMLwrt.WriteEndElement();
break;
}
XMLwrt.WriteEndElement();//value
}
private static void WriteStructValue(XmlWriter XMLwrt, XmlRpcValueStruct val)
{
XMLwrt.WriteStartElement("value");//value
XMLwrt.WriteStartElement("struct");//struct
foreach (XmlRpcStructMember member in val.Members)
{
XMLwrt.WriteStartElement("member");//member
XMLwrt.WriteStartElement("name");//name
XMLwrt.WriteString(member.Name);
XMLwrt.WriteEndElement();//name
if (member.Data is XmlRpcValueBasic)
{
WriteBasicValue(XMLwrt, (XmlRpcValueBasic)member.Data);
}
else if (member.Data is XmlRpcValueStruct)
{
WriteStructValue(XMLwrt, (XmlRpcValueStruct)member.Data);
}
else if (member.Data is XmlRpcValueArray)
{
WriteArrayValue(XMLwrt, (XmlRpcValueArray)member.Data);
}
XMLwrt.WriteEndElement();//member
}
XMLwrt.WriteEndElement();//struct
XMLwrt.WriteEndElement();//value
}
private static void WriteArrayValue(XmlWriter XMLwrt, XmlRpcValueArray val)
{
XMLwrt.WriteStartElement("value");//value
XMLwrt.WriteStartElement("array");//array
XMLwrt.WriteStartElement("data");//data
foreach (IXmlRpcValue o in val.Values)
{
if (o is XmlRpcValueBasic)
{
WriteBasicValue(XMLwrt, (XmlRpcValueBasic)o);
}
else if (o is XmlRpcValueStruct)
{
WriteStructValue(XMLwrt, (XmlRpcValueStruct)o);
}
else if (o is XmlRpcValueArray)
{
WriteArrayValue(XMLwrt, (XmlRpcValueArray)o);
}
}
XMLwrt.WriteEndElement();//data
XMLwrt.WriteEndElement();//array
XMLwrt.WriteEndElement();//value
}
private static IXmlRpcValue ReadValue(XmlReader xmlReader)
{
while (xmlReader.Read())
{
if (xmlReader.Name == "value" && xmlReader.IsStartElement())
{
xmlReader.Read();
if (xmlReader.Name == "string" && xmlReader.IsStartElement())
{
return new XmlRpcValueBasic(xmlReader.ReadString(), XmlRpcBasicValueType.String);
}
else if (xmlReader.Name == "int" && xmlReader.IsStartElement())
{
return new XmlRpcValueBasic(int.Parse(xmlReader.ReadString()), XmlRpcBasicValueType.Int);
}
else if (xmlReader.Name == "boolean" && xmlReader.IsStartElement())
{
return new XmlRpcValueBasic(xmlReader.ReadString() == "1", XmlRpcBasicValueType.Boolean);
}
else if (xmlReader.Name == "double" && xmlReader.IsStartElement())
{
return new XmlRpcValueBasic(double.Parse(xmlReader.ReadString()), XmlRpcBasicValueType.Double);
}
else if (xmlReader.Name == "dateTime.iso8601" && xmlReader.IsStartElement())
{
string date = xmlReader.ReadString();
int year = int.Parse(date.Substring(0, 4));
int month = int.Parse(date.Substring(4, 2));
int day = int.Parse(date.Substring(6, 2));
int hour = int.Parse(date.Substring(9, 2));
int minute = int.Parse(date.Substring(12, 2));//19980717T14:08:55
int sec = int.Parse(date.Substring(15, 2));
DateTime time = new DateTime(year, month, day, hour, minute, sec);
return new XmlRpcValueBasic(time, XmlRpcBasicValueType.dateTime_iso8601);
}
else if (xmlReader.Name == "base64" && xmlReader.IsStartElement())
{
return new XmlRpcValueBasic(BitConverter.ToInt64(Convert.FromBase64String(xmlReader.ReadString()), 0)
, XmlRpcBasicValueType.Double);
}
else if (xmlReader.Name == "struct" && xmlReader.IsStartElement())
{
XmlRpcValueStruct strct = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
// Read members...
while (xmlReader.Read())
{
if (xmlReader.Name == "member" && xmlReader.IsStartElement())
{
XmlRpcStructMember member = new XmlRpcStructMember("", null);
xmlReader.Read();// read name
member.Name = xmlReader.ReadString();
IXmlRpcValue val = ReadValue(xmlReader);
if (val != null)
{
member.Data = val;
strct.Members.Add(member);
}
}
else if (xmlReader.Name == "struct" && !xmlReader.IsStartElement())
{
return strct;
}
}
return strct;
}
else if (xmlReader.Name == "array" && xmlReader.IsStartElement())
{
XmlRpcValueArray array = new XmlRpcValueArray();
// Read members...
while (xmlReader.Read())
{
if (xmlReader.Name == "array" && !xmlReader.IsStartElement())
{
return array;
}
else
{
IXmlRpcValue val = ReadValue(xmlReader);
if (val != null)
array.Values.Add(val);
}
}
return array;
}
}
else break;
}
return null;
}
}
}