From: <gib...@us...> - 2009-12-25 13:45:40
|
Revision: 3301 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=3301&view=rev Author: gibman_dk Date: 2009-12-25 13:44:55 +0000 (Fri, 25 Dec 2009) Log Message: ----------- subtitlesretriever plugin helper initial commit. Added Paths: ----------- trunk/plugins/SubtitlesRetriever/ trunk/plugins/SubtitlesRetriever/External/ trunk/plugins/SubtitlesRetriever/External/7z.dll trunk/plugins/SubtitlesRetriever/External/SubtitleDownloader.dll trunk/plugins/SubtitlesRetriever/LocalizeStrings.cs trunk/plugins/SubtitlesRetriever/Properties/ trunk/plugins/SubtitlesRetriever/Properties/AssemblyInfo.cs trunk/plugins/SubtitlesRetriever/SubtitlesComparer.cs trunk/plugins/SubtitlesRetriever/SubtitlesDownloader.4.5.resharper.user trunk/plugins/SubtitlesRetriever/SubtitlesRetriever.4.5.resharper.user trunk/plugins/SubtitlesRetriever/SubtitlesRetriever.cs trunk/plugins/SubtitlesRetriever/SubtitlesRetriever.csproj trunk/plugins/SubtitlesRetriever/SubtitlesRetriever.csproj.user trunk/plugins/SubtitlesRetriever/SubtitlesRetriever.sln trunk/plugins/SubtitlesRetriever/SubtitlesRetriever.suo trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/ trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/CachesImage.bin trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/ProjectModel/ trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/ProjectModel/ProjectModel.dat trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/TodoCache/ trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/TodoCache/.version trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/TodoCache/0/ trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/TodoCache/1/ trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/TodoCache/1/5daef8ae.dat trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/WebsiteFileReferences/ trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/WebsiteFileReferences/.version trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/WordIndex.New/ trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/WordIndex.New/.version trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/WordIndex.New/0/ trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/WordIndex.New/4/ trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/WordIndex.New/4/3461a10a.dat trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/Xaml/ trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/Xaml/CacheProvider.dat trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesRetriever/ trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesRetriever/CachesImage.bin trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesRetriever/ProjectModel/ trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesRetriever/ProjectModel/ProjectModel.dat trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesRetriever/TodoCache/ trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesRetriever/TodoCache/.version trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesRetriever/TodoCache/0/ trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesRetriever/TodoCache/0/6ac899c5.dat trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesRetriever/WebsiteFileReferences/ trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesRetriever/WebsiteFileReferences/.version trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesRetriever/WordIndex.New/ trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesRetriever/WordIndex.New/.version trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesRetriever/WordIndex.New/7/ trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesRetriever/WordIndex.New/7/1bec845e.dat trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesRetriever/Xaml/ trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesRetriever/Xaml/CacheProvider.dat trunk/plugins/SubtitlesRetriever/bin/ trunk/plugins/SubtitlesRetriever/bin/Debug/ trunk/plugins/SubtitlesRetriever/bin/Debug/AxInterop.WMPLib.dll trunk/plugins/SubtitlesRetriever/bin/Debug/Bass.Net.dll trunk/plugins/SubtitlesRetriever/bin/Debug/BassRegistration.dll trunk/plugins/SubtitlesRetriever/bin/Debug/CSScriptLibrary.dll trunk/plugins/SubtitlesRetriever/bin/Debug/Core.dll trunk/plugins/SubtitlesRetriever/bin/Debug/Databases.dll trunk/plugins/SubtitlesRetriever/bin/Debug/Dialogs.dll trunk/plugins/SubtitlesRetriever/bin/Debug/DirectShowLib.dll trunk/plugins/SubtitlesRetriever/bin/Debug/Interop.SHDocVw.dll trunk/plugins/SubtitlesRetriever/bin/Debug/Interop.WMPLib.dll trunk/plugins/SubtitlesRetriever/bin/Debug/Ionic.Zip.dll trunk/plugins/SubtitlesRetriever/bin/Debug/MediaPortal.Support.dll trunk/plugins/SubtitlesRetriever/bin/Debug/SubtitleDownloader.dll trunk/plugins/SubtitlesRetriever/bin/Debug/SubtitlesDownloader.dll trunk/plugins/SubtitlesRetriever/bin/Debug/SubtitlesDownloader.pdb trunk/plugins/SubtitlesRetriever/bin/Debug/SubtitlesRetriever.dll trunk/plugins/SubtitlesRetriever/bin/Debug/SubtitlesRetriever.pdb trunk/plugins/SubtitlesRetriever/bin/Debug/Utils.dll trunk/plugins/SubtitlesRetriever/bin/Debug/edtftpnet-1.2.2.dll trunk/plugins/SubtitlesRetriever/bin/Debug/language/ trunk/plugins/SubtitlesRetriever/bin/Debug/language/SubtitlesRetriever/ trunk/plugins/SubtitlesRetriever/bin/Debug/language/SubtitlesRetriever/strings_da.xml trunk/plugins/SubtitlesRetriever/bin/Debug/language/SubtitlesRetriever/strings_en.xml trunk/plugins/SubtitlesRetriever/bin/Debug/taglib-sharp.dll trunk/plugins/SubtitlesRetriever/bin/Release/ trunk/plugins/SubtitlesRetriever/bin/Release/AxInterop.WMPLib.dll trunk/plugins/SubtitlesRetriever/bin/Release/Bass.Net.dll trunk/plugins/SubtitlesRetriever/bin/Release/BassRegistration.dll trunk/plugins/SubtitlesRetriever/bin/Release/CSScriptLibrary.dll trunk/plugins/SubtitlesRetriever/bin/Release/Core.dll trunk/plugins/SubtitlesRetriever/bin/Release/Databases.dll trunk/plugins/SubtitlesRetriever/bin/Release/Dialogs.dll trunk/plugins/SubtitlesRetriever/bin/Release/DirectShowLib.dll trunk/plugins/SubtitlesRetriever/bin/Release/Interop.SHDocVw.dll trunk/plugins/SubtitlesRetriever/bin/Release/Interop.WMPLib.dll trunk/plugins/SubtitlesRetriever/bin/Release/Ionic.Zip.dll trunk/plugins/SubtitlesRetriever/bin/Release/MediaPortal.Support.dll trunk/plugins/SubtitlesRetriever/bin/Release/SubtitleDownloader.dll trunk/plugins/SubtitlesRetriever/bin/Release/SubtitlesRetriever.dll trunk/plugins/SubtitlesRetriever/bin/Release/SubtitlesRetriever.pdb trunk/plugins/SubtitlesRetriever/bin/Release/Utils.dll trunk/plugins/SubtitlesRetriever/bin/Release/edtftpnet-1.2.2.dll trunk/plugins/SubtitlesRetriever/bin/Release/language/ trunk/plugins/SubtitlesRetriever/bin/Release/language/SubtitlesRetriever/ trunk/plugins/SubtitlesRetriever/bin/Release/language/SubtitlesRetriever/strings_da.xml trunk/plugins/SubtitlesRetriever/bin/Release/language/SubtitlesRetriever/strings_en.xml trunk/plugins/SubtitlesRetriever/bin/Release/taglib-sharp.dll trunk/plugins/SubtitlesRetriever/language/ trunk/plugins/SubtitlesRetriever/language/SubtitlesRetriever/ trunk/plugins/SubtitlesRetriever/language/SubtitlesRetriever/strings_da.xml trunk/plugins/SubtitlesRetriever/language/SubtitlesRetriever/strings_en.xml trunk/plugins/SubtitlesRetriever/obj/ trunk/plugins/SubtitlesRetriever/obj/Debug/ trunk/plugins/SubtitlesRetriever/obj/Debug/ResolveAssemblyReference.cache trunk/plugins/SubtitlesRetriever/obj/Debug/SubtitlesDownloader.csproj.FileListAbsolute.txt trunk/plugins/SubtitlesRetriever/obj/Debug/SubtitlesDownloader.dll trunk/plugins/SubtitlesRetriever/obj/Debug/SubtitlesDownloader.pdb trunk/plugins/SubtitlesRetriever/obj/Debug/SubtitlesRetriever.csproj.FileListAbsolute.txt trunk/plugins/SubtitlesRetriever/obj/Debug/SubtitlesRetriever.dll trunk/plugins/SubtitlesRetriever/obj/Debug/SubtitlesRetriever.pdb trunk/plugins/SubtitlesRetriever/obj/Debug/TempPE/ trunk/plugins/SubtitlesRetriever/obj/Release/ trunk/plugins/SubtitlesRetriever/obj/Release/ResolveAssemblyReference.cache trunk/plugins/SubtitlesRetriever/obj/Release/SubtitlesRetriever.csproj.FileListAbsolute.txt trunk/plugins/SubtitlesRetriever/obj/Release/SubtitlesRetriever.dll trunk/plugins/SubtitlesRetriever/obj/Release/SubtitlesRetriever.pdb trunk/plugins/SubtitlesRetriever/obj/Release/TempPE/ Added: trunk/plugins/SubtitlesRetriever/External/7z.dll =================================================================== (Binary files differ) Property changes on: trunk/plugins/SubtitlesRetriever/External/7z.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/plugins/SubtitlesRetriever/External/SubtitleDownloader.dll =================================================================== (Binary files differ) Property changes on: trunk/plugins/SubtitlesRetriever/External/SubtitleDownloader.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/plugins/SubtitlesRetriever/LocalizeStrings.cs =================================================================== --- trunk/plugins/SubtitlesRetriever/LocalizeStrings.cs (rev 0) +++ trunk/plugins/SubtitlesRetriever/LocalizeStrings.cs 2009-12-25 13:44:55 UTC (rev 3301) @@ -0,0 +1,260 @@ +#region Copyright (C) 2005-2007 Team MediaPortal + +/* + * Copyright (C) 2005-2007 Team MediaPortal + * http://www.team-mediaportal.com + * + * 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 2, 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 GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#endregion + +using System; +using System.IO; +using System.Globalization; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using System.Xml; +using MediaPortal.Util; +using MediaPortal.GUI.Library; +using MediaPortal.Configuration; +using MediaPortal.Localisation; + +namespace MediaPortal.Plugins.SubtitlesRetriever +{ + /// <summary> + /// This class will hold all text used in the application + /// The text is loaded for the current language from + /// the file language/[language]/strings.xml + /// </summary> + public class GUILocalizeStrings + { + #region Variables + static LocalisationProvider _stringProvider; + static Dictionary<string, string> _cultures; + static string[] _languages; + #endregion + + #region Constructors/Destructors + // singleton. Dont allow any instance of this class + private GUILocalizeStrings() + { + } + + static public void Dispose() + { + if (_stringProvider != null) + _stringProvider.Dispose(); + } + #endregion + + #region Public Methods + /// <summary> + /// Public method to load the text from a strings/xml file into memory + /// </summary> + /// <param name="strFileName">Contains the filename+path for the string.xml file</param> + /// <returns> + /// true when text is loaded + /// false when it was unable to load the text + /// </returns> + //[Obsolete("This method has changed", true)] + static public bool Load(string language) + { + bool isPrefixEnabled = true; + + using (MediaPortal.Profile.Settings reader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) + isPrefixEnabled = reader.GetValueAsBool("general", "myprefix", true); + + string directory = Config.GetSubFolder(Config.Dir.Language, "SubtitlesRetriever"); + string cultureName = null; + if (language != null) + cultureName = GetCultureName(language); + + Log.Info(" Loading localised Strings - Path: {0} Culture: {1} Language: {2} Prefix: {3}", directory, cultureName, language, isPrefixEnabled); + + _stringProvider = new LocalisationProvider(directory, cultureName, isPrefixEnabled); + + GUIGraphicsContext.CharsInCharacterSet = _stringProvider.Characters; + + return true; + } + + static public string CurrentLanguage() + { + if (_stringProvider == null) + Load(null); + + return _stringProvider.CurrentLanguage.EnglishName; + } + + static public void ChangeLanguage(string language) + { + if (_stringProvider == null) + Load(language); + else + _stringProvider.ChangeLanguage(GetCultureName(language)); + } + + /// <summary> + /// Get the translation for a given id and format the sting with + /// the given parameters + /// </summary> + /// <param name="dwCode">id of text</param> + /// <param name="parameters">parameters used in the formating</param> + /// <returns> + /// string containing the translated text + /// </returns> + static public string Get(int dwCode, object[] parameters) + { + if (_stringProvider == null) + Load(null); + + string translation = _stringProvider.GetString("unmapped", dwCode); + // if parameters or the translation is null, return the translation. + if ((translation == null) || (parameters == null)) + { + return translation; + } + // return the formatted string. If formatting fails, log the error + // and return the unformatted string. + try + { + return String.Format(translation, parameters); + } + catch (System.FormatException e) + { + Log.Error("Error formatting translation with id {0}", dwCode); + Log.Error("Unformatted translation: {0}", translation); + Log.Error(e); + return translation; + } + } + + /// <summary> + /// Get the translation for a given id + /// </summary> + /// <param name="dwCode">id of text</param> + /// <returns> + /// string containing the translated text + /// </returns> + static public string Get(int dwCode) + { + if (_stringProvider == null) + Load(null); + + string translation = _stringProvider.GetString("unmapped", dwCode); + + if (translation == null) + { + Log.Error("No translation found for id {0}", dwCode); + return String.Empty; + } + + return translation; + } + + static public void LocalizeLabel(ref string strLabel) + { + if (_stringProvider == null) + Load(null); + + if (strLabel == null) strLabel = String.Empty; + if (strLabel == "-") strLabel = ""; + if (strLabel == "") return; + // This can't be a valid string code if the first character isn't a number. + // This check will save us from catching unnecessary exceptions. + if (!char.IsNumber(strLabel, 0)) + return; + + int dwLabelID; + + try + { + dwLabelID = System.Int32.Parse(strLabel); + } + catch (FormatException e) + { + Log.Error(e); + strLabel = String.Empty; + return; + } + + strLabel = _stringProvider.GetString("unmapped", dwLabelID); + if (strLabel == null) + { + Log.Error("No translation found for id {0}", dwLabelID); + strLabel = String.Empty; + } + } + + public static string LocalSupported() + { + if (_stringProvider == null) + Load(null); + + CultureInfo culture = _stringProvider.GetBestLanguage(); + + return culture.EnglishName; + } + + public static string[] SupportedLanguages() + { + if (_languages == null) + { + if (_stringProvider == null) + Load(null); + + CultureInfo[] cultures = _stringProvider.AvailableLanguages(); + + SortedList sortedLanguages = new SortedList(); + foreach (CultureInfo culture in cultures) + sortedLanguages.Add(culture.EnglishName, culture.EnglishName); + + _languages = new string[sortedLanguages.Count]; + + for (int i = 0; i < sortedLanguages.Count; i++) + { + _languages[i] = (string)sortedLanguages.GetByIndex(i); + } + } + + return _languages; + } + + static public string GetCultureName(string language) + { + if (_cultures == null) + { + _cultures = new Dictionary<string, string>(); + + CultureInfo[] cultureList = CultureInfo.GetCultures(CultureTypes.AllCultures); + + for (int i = 0; i < cultureList.Length; i++) + { + _cultures.Add(cultureList[i].EnglishName, cultureList[i].Name); + } + } + + if (_cultures.ContainsKey(language)) + return _cultures[language]; + + return null; + } + #endregion + } +} \ No newline at end of file Added: trunk/plugins/SubtitlesRetriever/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/SubtitlesRetriever/Properties/AssemblyInfo.cs (rev 0) +++ trunk/plugins/SubtitlesRetriever/Properties/AssemblyInfo.cs 2009-12-25 13:44:55 UTC (rev 3301) @@ -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("SubtitlesDownloader")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("SubtitlesDownloader")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2009")] +[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("4fc474da-4e1a-4960-bb2b-8e568227e684")] + +// 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")] Added: trunk/plugins/SubtitlesRetriever/SubtitlesComparer.cs =================================================================== --- trunk/plugins/SubtitlesRetriever/SubtitlesComparer.cs (rev 0) +++ trunk/plugins/SubtitlesRetriever/SubtitlesComparer.cs 2009-12-25 13:44:55 UTC (rev 3301) @@ -0,0 +1,93 @@ +//extern alias subtitles; +//using SubtitlesDL = subtitles::SubtitleDownloader; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace MediaPortal.Plugins.SubtitlesRetriever +{ + public class SubtitleComparer : IComparer<SubtitleItem> + { + + private readonly string[] _langs; + + #region IComparer<SubtitleItem> Members + public SubtitleComparer (string[] langs) + { + _langs = langs; + } + + public int Compare(SubtitleItem subTitleItem1, SubtitleItem subTitleItem2) + { + int returnValue = 1; + int retVal = 0; + + SubtitleDownloader.Core.Subtitle sub1 = subTitleItem1.Subtitle; + SubtitleDownloader.Core.Subtitle sub2 = subTitleItem2.Subtitle; + + string sub1HasLang = ""; + string sub2HasLang = ""; + int sub1FoundSubtitlePriority = -1; // the higher nr, the lower prio. + int sub2FoundSubtitlePriority = -1; + + int i = 0; + if (sub1 != null && sub2 != null) + { + foreach (string lang in _langs) + { + if (string.IsNullOrEmpty(lang)) + { + continue; + } + + if (string.IsNullOrEmpty(sub1HasLang)) + { + if (subTitleItem1.Subtitle.LanguageCode.Contains(lang)) + { + sub1HasLang = subTitleItem1.Subtitle.LanguageCode; + sub1FoundSubtitlePriority = i; + } + } + + if (string.IsNullOrEmpty(sub2HasLang)) + { + if (subTitleItem2.Subtitle.LanguageCode.Contains(lang)) + { + sub2HasLang = subTitleItem2.Subtitle.LanguageCode; + sub2FoundSubtitlePriority = i; + } + } + i++; + } + + if (sub1FoundSubtitlePriority > -1 && sub2FoundSubtitlePriority > -1) //prio. subs found + { + if (sub1FoundSubtitlePriority > sub2FoundSubtitlePriority) + { + return 1; + } + else if (sub1FoundSubtitlePriority < sub2FoundSubtitlePriority) + { + return -1; + } + else + { + return 0; + } + + } + else + { + returnValue = sub1.LanguageCode.CompareTo(sub2.LanguageCode); + } + } + + return returnValue; + } + + #endregion + } + +} Added: trunk/plugins/SubtitlesRetriever/SubtitlesDownloader.4.5.resharper.user =================================================================== --- trunk/plugins/SubtitlesRetriever/SubtitlesDownloader.4.5.resharper.user (rev 0) +++ trunk/plugins/SubtitlesRetriever/SubtitlesDownloader.4.5.resharper.user 2009-12-25 13:44:55 UTC (rev 3301) @@ -0,0 +1,58 @@ +<Configuration> + <SettingsComponent> + <string /> + <integer /> + <boolean> + <setting name="SolutionAnalysisEnabled">False</setting> + </boolean> + </SettingsComponent> + <NAntValidationSettings> + <NAntPath value="" /> + </NAntValidationSettings> + <RecentFiles> + <RecentFiles> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/f:SubtitlesComparer.cs" caret="224" fromTop="8" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/f:LocalizeStrings.cs" caret="1509" fromTop="44" /> + </RecentFiles> + <RecentEdits> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/f:LocalizeStrings.cs" caret="2782" fromTop="17" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/f:SubtitlesComparer.cs" caret="223" fromTop="8" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/f:LocalizeStrings.cs" caret="1271" fromTop="37" /> + </RecentEdits> + </RecentFiles> + <UnitTestRunner> + <Providers /> + </UnitTestRunner> + <CompletionStatisticsManager> + <ItemStatistics item="Default"> + <Item value="using" priority="0" /> + <Item value="SubtitleDownloader" priority="1" /> + <Item value="bool" priority="2" /> + <Item value="string" priority="2" /> + <Item value="if" priority="0" /> + <Item value="foreach" priority="0" /> + <Item value="StringWriter" priority="2" /> + <Item value="null" priority="0" /> + <Item value="Length" priority="0" /> + <Item value="in" priority="0" /> + <Item value="providers" priority="0" /> + <Item value="switch" priority="0" /> + <Item value="case" priority="0" /> + <Item value="break" priority="0" /> + <Item value="true" priority="0" /> + <Item value="enum" priority="0" /> + <Item value="GUILocalizeStrings" priority="0" /> + </ItemStatistics> + <ItemStatistics item="Qualified:@System.String"> + <Item value="Empty" priority="0" /> + <Item value="IsNullOrEmpty" priority="0" /> + </ItemStatistics> + <ItemStatistics item="Qualified:@MediaPortal.Plugins.SubtitlesRetriever.Translation"> + <Item value="NoSubtitlesFound" priority="0" /> + <Item value="SubtitlesAlreadyExist" priority="0" /> + </ItemStatistics> + <ItemStatistics item="Qualified:@MediaPortal.Plugins.SubtitlesRetriever.GUILocalizeStrings"> + <Item value="Get" priority="0" /> + </ItemStatistics> + </CompletionStatisticsManager> +</Configuration> \ No newline at end of file Added: trunk/plugins/SubtitlesRetriever/SubtitlesRetriever.4.5.resharper.user =================================================================== --- trunk/plugins/SubtitlesRetriever/SubtitlesRetriever.4.5.resharper.user (rev 0) +++ trunk/plugins/SubtitlesRetriever/SubtitlesRetriever.4.5.resharper.user 2009-12-25 13:44:55 UTC (rev 3301) @@ -0,0 +1,77 @@ +<Configuration> + <SettingsComponent> + <string /> + <integer /> + <boolean> + <setting name="SolutionAnalysisEnabled">False</setting> + </boolean> + </SettingsComponent> + <NAntValidationSettings> + <NAntPath value="" /> + </NAntValidationSettings> + <RecentFiles> + <RecentFiles> + <File id="d:Miscellaneous Files/f:TVOverlay.cs/l:C!?Development?TvEngine3?TVLibrary?TvPlugin?TvPlugin?TVOverlay.cs" caret="2241" fromTop="17" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/f:LocalizeStrings.cs" caret="5171" fromTop="21" /> + <File id="6DA0E4DF-6230-4642-98B5-E690BB6942BB/d:Localisation/f:LocalisationProvider.cs" caret="9600" fromTop="23" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/d:language/d:SubtitlesRetriever/f:da.xml" caret="349" fromTop="8" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/d:language/d:SubtitlesRetriever/f:en.xml" caret="326" fromTop="8" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/f:SubtitlesRetriever.cs" caret="16353" fromTop="566" /> + </RecentFiles> + <RecentEdits> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/d:language/d:SubtitlesRetriever/f:da.xml" caret="0" fromTop="0" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/d:language/d:SubtitlesRetriever/f:en.xml" caret="335" fromTop="8" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/f:SubtitlesRetriever.cs" caret="4022" fromTop="44" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/f:SubtitlesRetriever.cs" caret="3670" fromTop="36" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/d:language/d:SubtitlesRetriever/f:da.xml" caret="349" fromTop="8" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/d:language/d:SubtitlesRetriever/f:en.xml" caret="326" fromTop="8" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/f:SubtitlesRetriever.cs" caret="11575" fromTop="11" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/f:SubtitlesRetriever.cs" caret="5684" fromTop="9" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/f:SubtitlesRetriever.cs" caret="4186" fromTop="9" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/f:SubtitlesRetriever.cs" caret="4835" fromTop="24" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/f:SubtitlesRetriever.cs" caret="16115" fromTop="20" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/f:SubtitlesRetriever.cs" caret="16115" fromTop="17" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/f:SubtitlesRetriever.cs" caret="16086" fromTop="20" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/f:SubtitlesRetriever.cs" caret="16086" fromTop="20" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/f:SubtitlesRetriever.cs" caret="17677" fromTop="34" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/f:SubtitlesRetriever.cs" caret="1901" fromTop="15" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/f:SubtitlesRetriever.cs" caret="1947" fromTop="19" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/f:SubtitlesRetriever.cs" caret="1993" fromTop="23" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/f:SubtitlesRetriever.cs" caret="795" fromTop="15" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/f:SubtitlesRetriever.cs" caret="15579" fromTop="15" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/f:SubtitlesRetriever.cs" caret="15820" fromTop="19" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/f:SubtitlesRetriever.cs" caret="16075" fromTop="26" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/f:SubtitlesRetriever.cs" caret="16445" fromTop="9" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/f:SubtitlesRetriever.cs" caret="15399" fromTop="11" /> + <File id="851E199C-0E56-4AF0-9577-DA47FD234A41/f:SubtitlesRetriever.cs" caret="16663" fromTop="17" /> + </RecentEdits> + </RecentFiles> + <UnitTestRunner> + <Providers /> + </UnitTestRunner> + <CompletionStatisticsManager> + <ItemStatistics item="Default"> + <Item value="string" priority="0" /> + <Item value="query" priority="0" /> + <Item value="EpisodeSearchQuery" priority="1" /> + <Item value="if" priority="4" /> + <Item value="mediaDetail" priority="2" /> + <Item value="else" priority="1" /> + <Item value="new" priority="0" /> + <Item value="false" priority="0" /> + <Item value="useMoviequery" priority="1" /> + <Item value="useSeriesquery" priority="1" /> + <Item value="useIMDBquery" priority="0" /> + </ItemStatistics> + <ItemStatistics item="Qualified:System.String"> + <Item value="Split" priority="0" /> + </ItemStatistics> + <ItemStatistics item="Qualified:@System.String"> + <Item value="IsNullOrEmpty" priority="0" /> + </ItemStatistics> + <ItemStatistics item="Qualified:MediaPortal.Plugins.SubtitlesRetriever.BasicMediaDetail"> + <Item value="Episode" priority="1" /> + <Item value="Title" priority="0" /> + </ItemStatistics> + </CompletionStatisticsManager> +</Configuration> \ No newline at end of file Added: trunk/plugins/SubtitlesRetriever/SubtitlesRetriever.cs =================================================================== --- trunk/plugins/SubtitlesRetriever/SubtitlesRetriever.cs (rev 0) +++ trunk/plugins/SubtitlesRetriever/SubtitlesRetriever.cs 2009-12-25 13:44:55 UTC (rev 3301) @@ -0,0 +1,664 @@ +// the subtitlesdownloader assembly has a conflict on the CookComputing reference +// using an alias to overcome this. +//extern alias subtitles; +//using SubtitlesDL = subtitles::SubtitleDownloader; +using MediaPortal.Dialogs; +using MediaPortal.GUI.Library; +using MediaPortal.Player; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO; +using SubtitleDownloader; +using SubtitleDownloader.Core; + +namespace MediaPortal.Plugins.SubtitlesRetriever +{ + #region public structs + + public struct BasicMediaDetail + { + private string _fullPath; + private string _fileName; + private string _title; + private string _imdbID; + private int _nr; + private int _year; + private int _episode; + private int _season; + private int? _mediaId; + + + public int? MediaId + { + get + { + return _mediaId; + } + set + { + _mediaId = value; + } + } + + + public string ImdbID + { + get + { + return _imdbID; + } + set + { + _imdbID = value; + } + } + + public string FullPath + { + get + { + return _fullPath; + } + set + { + _fullPath = value; + } + } + + public string FileName + { + get + { + return _fileName; + } + set + { + _fileName = value; + } + } + + public string Title + { + get + { + return _title; + } + set + { + _title = value; + } + } + + public int Number + { + get + { + return _nr; + } + set + { + _nr = value; + } + } + + public int Year + { + get + { + return _year; + } + set + { + _year = value; + } + } + + + public int Season + { + get + { + return _season; + } + set + { + _season = value; + } + } + + public int Episode + { + get + { + return _episode; + } + set + { + _episode = value; + } + } + } + + public struct SubtitleItem + { + private SubtitleDownloader.Core.Subtitle _subtitle; + private SubtitleDownloader.Core.ISubtitleDownloader _downloader; + + public SubtitleDownloader.Core.Subtitle Subtitle + { + get + { + return _subtitle; + } + set + { + _subtitle = value; + } + } + + public SubtitleDownloader.Core.ISubtitleDownloader Downloader + { + get + { + return _downloader; + } + set + { + _downloader = value; + } + } + } + + #endregion + + #region internal structs + + + #endregion + + #region private enums + + enum Translation + { + SubtitlesAlreadyExist = 0, + NoSubtitlesFound = 1, + SubtitlesDownloaded = 2 + } + + #endregion + + public class SubtitlesRetriever + { + #region private vars + + private bool _enabled = false; + private string[] _languages; + private bool _useOpensubtitles = false; + private bool _useBierdopje = false; + private bool _usePodnapisi = false; + private bool _useSublight = false; + private bool _useSubscene = false; + private bool _useSubtitleSource = false; + private bool _useTVSubtitles = false; + + #endregion + + #region public events + + public delegate void OnSubtitleDownloadedDelegate (BasicMediaDetail mediaDetail); + + public event OnSubtitleDownloadedDelegate OnSubtitleDownloadedEvent; + + #endregion + + #region public constants + + public const string OPENSUBTITLES = "opensubtitles"; + public const string BIERDOPJE = "bierdopje"; + public const string PODNAPISI = "podnapisi"; + public const string SUBLIGHT = "sublight"; + public const string SUBSCENE = "subscene"; + public const string SUBTITLESOURCE = "subtitleSource"; + public const string TVSUBTITLES = "tvsubtitles"; + + #endregion + + #region constructors + + public SubtitlesRetriever(bool enabled, string prefLanguages, string providers) + { + GUILocalizeStrings.Load(GUI.Library.GUILocalizeStrings.CurrentLanguage()); + + _enabled = enabled; // MovingPicturesCore.Settings.SubtitleDownloaderEnabled; + // MovingPicturesCore.Settings.SubtitlesDownloaderLanguages; + + if (string.IsNullOrEmpty(prefLanguages)) + { + _languages = new string[1]; + _languages[0] = "eng"; //default + } + else + { + _languages = prefLanguages.Split(';'); + } + + + if (!string.IsNullOrEmpty(providers)) + { + string[] providersArr = providers.Split(';'); + foreach (string provider in providersArr) + { + switch (provider) + { + case OPENSUBTITLES: + _useOpensubtitles = true; + break; + case BIERDOPJE: + _useBierdopje = true; + break; + case PODNAPISI: + _usePodnapisi = true; + break; + case SUBLIGHT: + _useSublight = true; + break; + case SUBSCENE: + _useSubscene = true; + break; + case SUBTITLESOURCE: + _useSubtitleSource = true; + break; + case TVSUBTITLES: + _useTVSubtitles = true; + break; + + //add more providers if needed + } + } + } + } + + #endregion + + #region public methods + + public void DownloadSubtitles(List<BasicMediaDetail> mediaDetails) + { + if (!_enabled) + { + return; + } + + List<SubtitleDownloader.Core.ISubtitleDownloader> downloaders = HarvestDownloaders(); + List<SubtitleDownloader.Core.Subtitle> resultsOpenSubtitles = new List<SubtitleDownloader.Core.Subtitle>(); + + //bool isMultipleDiscs = (mediaDetails.Count > 1); + + /*if (isMultipleDiscs && mediaDetail.Number == 1) + { + GUIDialogOK dialog = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); + if (dialog != null) + { + dialog.SetHeading(Translation.SubtitlesMultipleDiscs); + dialog.SetLine(1, Translation.SubtitlesSearchingDisc + " 1-" + Convert.ToString(mediaDetails.Count)); + dialog.SetLine(2, ""); + dialog.DoModal(GUIWindowManager.ActiveWindow); + } + } */ + + List<SubtitleItem> allResults = null; + foreach (BasicMediaDetail mediaDetail in mediaDetails) + { + allResults = QueryDownloaders(mediaDetail, downloaders); + } + + // all results gathered, now report back to the user the list of subs avail, + // keep showing the menu as long as there is subtitles avail. and if the user decides to stay on the menu + if (allResults != null && allResults.Count > 0) + { + while (true) + { + //GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_DIALOG_MENU); + int selectedIndex = PresentUserWithResults(mediaDetails[0], allResults); + if (selectedIndex < 0) + { + break; //nothing selected + } + DownloadSubtitle(mediaDetails, allResults, selectedIndex); + } + } + else + { + ShowMessage("Moving Pictures", GUILocalizeStrings.Get((int)Translation.NoSubtitlesFound), "", "", ""); + } + + } + + #endregion + + #region private methods + + /// <summary> + /// Displays a yes/no dialog with custom labels for the buttons + /// This method may become obsolete in the future if media portal adds more dialogs + /// </summary> + /// <returns>True if yes was clicked, False if no was clicked</returns> + public bool ShowCustomYesNo(string heading, string lines, string yesLabel, string noLabel, bool defaultYes) + { + GUIDialogYesNo dialog = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); + try + { + dialog.Reset(); + dialog.SetHeading(heading); + string[] linesArray = lines.Split(new string[] { "\\n" }, StringSplitOptions.None); + if (linesArray.Length > 0) dialog.SetLine(1, linesArray[0]); + if (linesArray.Length > 1) dialog.SetLine(2, linesArray[1]); + if (linesArray.Length > 2) dialog.SetLine(3, linesArray[2]); + if (linesArray.Length > 3) dialog.SetLine(4, linesArray[3]); + dialog.SetDefaultToYes(defaultYes); + + foreach (System.Windows.UIElement item in dialog.Children) + { + if (item is GUIButtonControl) + { + GUIButtonControl btn = (GUIButtonControl)item; + if (btn.GetID == 11 && !String.IsNullOrEmpty(yesLabel)) // Yes button + btn.Label = yesLabel; + else if (btn.GetID == 10 && !String.IsNullOrEmpty(noLabel)) // No button + btn.Label = noLabel; + } + } + dialog.DoModal(GUIWindowManager.ActiveWindow); + return dialog.IsConfirmed; + } + finally + { + // set the standard yes/no dialog back to it's original state (yes/no buttons) + if (dialog != null) + { + dialog.ClearAll(); + } + } + } + + public void ShowMessage(string heading, string line1, string line2, string line3, string line4) + { + GUIDialogOK dialog = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); + dialog.Reset(); + dialog.SetHeading(heading); + if (line1 != null) dialog.SetLine(1, line1); + if (line2 != null) dialog.SetLine(2, line2); + if (line3 != null) dialog.SetLine(3, line3); + if (line4 != null) dialog.SetLine(4, line4); + dialog.DoModal(GUIWindowManager.ActiveWindow); + } + + private void DownloadSubtitle(List<BasicMediaDetail> mediaDetails, List<SubtitleItem> allResults, int selectedIndex) + { + SubtitleDownloader.Core.ISubtitleDownloader subDownloader = allResults[selectedIndex].Downloader; + SubtitleDownloader.Core.Subtitle subtitle = allResults[selectedIndex].Subtitle;//FindSelectedSubtitle(allResults, selectedIndex, out subDownloader); + bool subtitleSaved = false; + bool? bOverwriteFile = null; + + List <FileInfo> subtitleFiles = subDownloader.SaveSubtitle(subtitle); + + int subtitleNr = 0; + foreach (FileInfo subtitleFile in subtitleFiles) + { + if (mediaDetails.Count <= subtitleNr) + { + break; // we found multiple subtitles, but we only have 1 disc. + } + BasicMediaDetail mediaDetail = mediaDetails[subtitleNr]; + string videoFileName = mediaDetail.FullPath.ToLower(); //mediaDetail.LocalMedia[0].FullPath.ToLower(); + + string targetSubtitleFile = + SubtitleDownloader.Util.FileUtils.GetFileNameForSubtitle(subtitleFile.Name, + subtitle.LanguageCode, + videoFileName); + + bool targetFileExists = File.Exists(targetSubtitleFile); + if (targetFileExists) + { + if (!bOverwriteFile.HasValue) + { + bOverwriteFile = (bool) ShowCustomYesNo("Moving Pictures", GUILocalizeStrings.Get((int)Translation.SubtitlesAlreadyExist), null, + null, false); + } + if ((bool)bOverwriteFile) + { + try + { + File.Delete(targetSubtitleFile); + } + catch (Exception) + { + //ignore + } + } + } + + targetFileExists = File.Exists(targetSubtitleFile); + if (!targetFileExists) + { + File.Move(subtitleFile.FullName, targetSubtitleFile); + allResults.RemoveAt(selectedIndex); + subtitleSaved = true; + } + subtitleNr++; + } + if (subtitleSaved) + { + NotifyUserSubtitleDownloaded(mediaDetails[0]); + } + } + + private GUIDialogSelect SetupGUIDialogue(BasicMediaDetail mediaDetail) + { + GUIDialogSelect dlg = + (GUIDialogSelect)GUIWindowManager.GetWindow((int)MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_DIALOG_SELECT); + if (dlg == null) + { + return null; + } + + GUIPropertyManager.SetProperty("#selecteditem", mediaDetail.FileName);//mediaDetail.LocalMedia[0].File.Name); + dlg.SetHeading(""); + dlg.EnableButton(true); + dlg.SetButtonLabel(2087); // backwards + return dlg; + } + + private void NotifyUserSubtitleDownloaded(BasicMediaDetail mediaDetail) + { + GUIDialogNotify pDlgNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_DIALOG_NOTIFY); + if (pDlgNotify == null) + { + return; + } + string caption = mediaDetail.Title; + + string subtitlesThumbPath = GUIGraphicsContext.Skin; + subtitlesThumbPath += "\\Media\\Logos\\subtitles.png"; + + pDlgNotify.SetHeading(caption); + pDlgNotify.SetImage(subtitlesThumbPath); + pDlgNotify.SetText(GUILocalizeStrings.Get((int)Translation.SubtitlesDownloaded)); + pDlgNotify.DoModal(GUIWindowManager.ActiveWindow); + + if (OnSubtitleDownloadedEvent!= null) + { + //maybe the subscriber wants to update the mediaInfo stuff :) + OnSubtitleDownloadedEvent(mediaDetail); + } + } + + private int PresentUserWithResults(BasicMediaDetail mediaDetail, List<SubtitleItem> allResults) + { + int selectedIndex = -1; + GUIDialogSelect dlg = SetupGUIDialogue(mediaDetail); + if (dlg == null) + { + return selectedIndex; + } + + bool subsFound = false; + + foreach (SubtitleItem subItem in allResults) + { + dlg.Add(subItem.Subtitle.LanguageCode + " " + subItem.Subtitle.FileName); + subsFound = true; + } + + if (!subsFound) + { + return selectedIndex; + } + + dlg.DoModal(GUIWindowManager.ActiveWindow); + + if (dlg.SelectedLabel < 0) + { + return selectedIndex; + } + + return dlg.SelectedLabel; + } + + private List<SubtitleItem> QueryDownloaders(BasicMediaDetail mediaDetail, List<SubtitleDownloader.Core.ISubtitleDownloader> downloaders) + { + List<SubtitleItem> allResults = new List<SubtitleItem>(); + SubtitleDownloader.Core.EpisodeSearchQuery episodeQuery = null; + SubtitleDownloader.Core.SearchQuery movieQuery = null; + SubtitleDownloader.Core.ImdbSearchQuery queryIMDB = null; + + bool useImdbQuery = false; + bool useMovieQuery = false; + bool useEpisodeQuery = false; + + if (mediaDetail.Episode > 0 && mediaDetail.Season > 0) + { + episodeQuery = new EpisodeSearchQuery(mediaDetail.Title, mediaDetail.Season, mediaDetail.Episode); + } + else + { + movieQuery = new SubtitleDownloader.Core.SearchQuery(mediaDetail.Title); + movieQuery.Year = mediaDetail.Year; + movieQuery.LanguageCodes = _languages; + + bool useIMDBquery = !(string.IsNullOrEmpty((mediaDetail.ImdbID))); + + if (useIMDBquery) + { + queryIMDB = new SubtitleDownloader.Core.ImdbSearchQuery(mediaDetail.ImdbID); + queryIMDB.LanguageCodes = _languages; + } + } + + + int subsTotal = 0; + foreach (SubtitleDownloader.Core.ISubtitleDownloader subsDownloader in downloaders) + { + List<SubtitleDownloader.Core.Subtitle> resultsFromDownloader = null; + + if (useEpisodeQuery) + { + resultsFromDownloader = subsDownloader.SearchSubtitles(episodeQuery); + } + else if (useMovieQuery) + { + resultsFromDownloader = subsDownloader.SearchSubtitles(movieQuery); + } + else if (useImdbQuery) + { + try + { + resultsFromDownloader = subsDownloader.SearchSubtitles(queryIMDB); + } + catch (NotSupportedException) + { + try + { + resultsFromDownloader = subsDownloader.SearchSubtitles(movieQuery); //lets do basic subs lookup instead + } + catch (Exception) + { + //ignore + } + } + catch (Exception) + { + //ignore + } + } + if (resultsFromDownloader != null && resultsFromDownloader.Count > 0) + { + foreach (SubtitleDownloader.Core.Subtitle subtitle in resultsFromDownloader) + { + SubtitleItem subItem = new SubtitleItem(); + subItem.Downloader = subsDownloader; + subItem.Subtitle = subtitle; + allResults.Add(subItem); + } + subsTotal += resultsFromDownloader.Count; + } + } + + //lets sort the results by lang. prefs. + allResults.Sort(new SubtitleComparer(_languages)); + + return allResults; + } + + private List<SubtitleDownloader.Core.ISubtitleDownloader> HarvestDownloaders() + { + List<SubtitleDownloader.Core.ISubtitleDownloader> downloaders = new List<SubtitleDownloader.Core.ISubtitleDownloader>(); + if (_useOpensubtitles) + { + SubtitleDownloader.Core.ISubtitleDownloader downloader = new SubtitleDownloader.Implementations.OpenSubtitles.OpenSubtitlesDownloader(); + downloaders.Add(downloader); + } + + if (_useBierdopje) + { + SubtitleDownloader.Core.ISubtitleDownloader downloader = new SubtitleDownloader.Implementations.Bierdopje.BierdopjeDownloader(); + downloaders.Add(downloader); + } + + if (_usePodnapisi) + { + SubtitleDownloader.Core.ISubtitleDownloader downloader = new SubtitleDownloader.Implementations.Podnapisi.PodnapisiDownloader(); + downloaders.Add(downloader); + } + + if (_useSublight) + { + SubtitleDownloader.Core.ISubtitleDownloader downloader = new SubtitleDownloader.Implementations.Sublight.SublightDownloader(); + downloaders.Add(downloader); + } + + if (_useSubscene) + { + SubtitleDownloader.Core.ISubtitleDownloader downloader = new SubtitleDownloader.Implementations.Subscene.SubsceneDownloader(); + downloaders.Add(downloader); + } + + if (_useSubtitleSource) + { + SubtitleDownloader.Core.ISubtitleDownloader downloader = new SubtitleDownloader.Implementations.SubtitleSource.SubtitleSourceDownloaderV2(); + downloaders.Add(downloader); + } + + if (_useTVSubtitles) + { + SubtitleDownloader.Core.ISubtitleDownloader downloader = new SubtitleDownloader.Implementations.TVSubtitles.TvSubtitlesDownloader(); + downloaders.Add(downloader); + } + return downloaders; + } + #endregion + } +} Added: trunk/plugins/SubtitlesRetriever/SubtitlesRetriever.csproj =================================================================== --- trunk/plugins/SubtitlesRetriever/SubtitlesRetriever.csproj (rev 0) +++ trunk/plugins/SubtitlesRetriever/SubtitlesRetriever.csproj 2009-12-25 13:44:55 UTC (rev 3301) @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>9.0.30729</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{851E199C-0E56-4AF0-9577-DA47FD234A41}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>SubtitlesDownloader</RootNamespace> + <AssemblyName>SubtitlesRetriever</AssemblyName> + <TargetFrameworkVersion>v3.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="Core, Version=1.0.4.23422, Culture=neutral, processorArchitecture=x86"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\mediaportal\Core\bin\Release\Core.dll</HintPath> + </Reference> + <Reference Include="Dialogs, Version=1.0.4.23425, Culture=neutral, processorArchitecture=x86"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\mediaportal\Dialogs\bin\Release\Dialogs.dll</HintPath> + </Reference> + <Reference Include="SubtitleDownloader, Version=0.9.0.0, Culture=neutral, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>External\SubtitleDownloader.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Core"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Xml.Linq"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Data.DataSetExtensions"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + <Reference Include="Utils, Version=2.2.7.23419, Culture=neutral, processorArchitecture=x86"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\mediaportal\Utils\bin\Release\Utils.dll</HintPath> + </Reference> + </ItemGroup> + <ItemGroup> + <Compile Include="LocalizeStrings.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="SubtitlesRetriever.cs" /> + <Compile Include="SubtitlesComparer.cs" /> + </ItemGroup> + <ItemGroup> + <Content Include="language\SubtitlesRetriever\strings_da.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="language\SubtitlesRetriever\strings_en.xml"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + </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> \ No newline at end of file Added: trunk/plugins/SubtitlesRetriever/SubtitlesRetriever.csproj.user =================================================================== --- trunk/plugins/SubtitlesRetriever/SubtitlesRetriever.csproj.user (rev 0) +++ trunk/plugins/SubtitlesRetriever/SubtitlesRetriever.csproj.user 2009-12-25 13:44:55 UTC (rev 3301) @@ -0,0 +1,5 @@ +<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <ProjectView>ProjectFiles</ProjectView> + </PropertyGroup> +</Project> \ No newline at end of file Added: trunk/plugins/SubtitlesRetriever/SubtitlesRetriever.sln =================================================================== --- trunk/plugins/SubtitlesRetriever/SubtitlesRetriever.sln (rev 0) +++ trunk/plugins/SubtitlesRetriever/SubtitlesRetriever.sln 2009-12-25 13:44:55 UTC (rev 3301) @@ -0,0 +1,34 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SubtitlesRetriever", "SubtitlesRetriever.csproj", "{851E199C-0E56-4AF0-9577-DA47FD234A41}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils", "..\..\mediaportal\Utils\Utils.csproj", "{6DA0E4DF-6230-4642-98B5-E690BB6942BB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {851E199C-0E56-4AF0-9577-DA47FD234A41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {851E199C-0E56-4AF0-9577-DA47FD234A41}.Debug|Any CPU.Build.0 = Debug|Any CPU + {851E199C-0E56-4AF0-9577-DA47FD234A41}.Debug|x86.ActiveCfg = Debug|Any CPU + {851E199C-0E56-4AF0-9577-DA47FD234A41}.Release|Any CPU.ActiveCfg = Release|Any CPU + {851E199C-0E56-4AF0-9577-DA47FD234A41}.Release|Any CPU.Build.0 = Release|Any CPU + {851E199C-0E56-4AF0-9577-DA47FD234A41}.Release|x86.ActiveCfg = Release|Any CPU + {6DA0E4DF-6230-4642-98B5-E690BB6942BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6DA0E4DF-6230-4642-98B5-E690BB6942BB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6DA0E4DF-6230-4642-98B5-E690BB6942BB}.Debug|x86.ActiveCfg = Debug|x86 + {6DA0E4DF-6230-4642-98B5-E690BB6942BB}.Debug|x86.Build.0 = Debug|x86 + {6DA0E4DF-6230-4642-98B5-E690BB6942BB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6DA0E4DF-6230-4642-98B5-E690BB6942BB}.Release|Any CPU.Build.0 = Release|Any CPU + {6DA0E4DF-6230-4642-98B5-E690BB6942BB}.Release|x86.ActiveCfg = Release|x86 + {6DA0E4DF-6230-4642-98B5-E690BB6942BB}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal Added: trunk/plugins/SubtitlesRetriever/SubtitlesRetriever.suo =================================================================== (Binary files differ) Property changes on: trunk/plugins/SubtitlesRetriever/SubtitlesRetriever.suo ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/CachesImage.bin =================================================================== (Binary files differ) Property changes on: trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/CachesImage.bin ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/ProjectModel/ProjectModel.dat =================================================================== (Binary files differ) Property changes on: trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/ProjectModel/ProjectModel.dat ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/TodoCache/.version =================================================================== (Binary files differ) Property changes on: trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/TodoCache/.version ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/TodoCache/1/5daef8ae.dat =================================================================== (Binary files differ) Property changes on: trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/TodoCache/1/5daef8ae.dat ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/WebsiteFileReferences/.version =================================================================== (Binary files differ) Property changes on: trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/WebsiteFileReferences/.version ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/WordIndex.New/.version =================================================================== (Binary files differ) Property changes on: trunk/plugins/SubtitlesRetriever/_ReSharper.SubtitlesDownloader/WordIndex.New/.version ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/plugin... [truncated message content] |