SubtitleDownloader (2 Viewers)

seco

Development Group
  • Team MediaPortal
  • August 7, 2007
    1,580
    1,236
    Finland Finland
    Country flag
    • Thread starter
    • Moderator
    • #1
    SubtitleDownloader is a C# API library for downloading subtitles from various multi-language subtitle sites.
    It was originally developed to be used with MediaPortal plugins but it can be also used in any .NET project.

    Note: SubtitleDownloader is not a plugin for Mediaportal, My TVSeries or Moving Pictures. It is a standalone library which can be easily re-used in C# applications such as Mediaportal plugins and MP2. This way subtitle sites, searching & downloading logic can be centralized to one library and not directly to one specific plugin.

    If you find the project useful, you can support the development by donating via PayPal
     
    Last edited:

    seco

    Development Group
  • Team MediaPortal
  • August 7, 2007
    1,580
    1,236
    Finland Finland
    Country flag
    • Thread starter
    • Moderator
    • #2
    Code examples

    Searching subtitles
    Code:
    ISubtitlesDownloader downloader = new OpenSubtitlesDownloader();
    SearchQuery query = new SearchQuery("batman");
    query.Year = "2005";
    query.LanguageCodes = new string[] { "fin", "swe" };
    
    List<Subtitle> results = downloader.SearchSubtitles(query); // return Finnish and Swedish subtitles for "Batman Begins";
    ISubtitlesDownloader downloader = new SubtitleSourceDownloaderV2();
    ImdbSearchQuery query = new ImdbSearchQuery("0372784");
    query.LanguageCodes = new string[] { Languages.GetLanguageCode("Swedish") };
    
    List<Subtitle> results = downloader.SearchSubtitles(query); // return Swedish subtitles for "Batman Begins";
    ISubtitlesDownloader downloader = new SublightDownloader();
    
    EpisodeSearchQuery query = new EpisodeSearchQuery("Heroes", 1, 3);
    //query.LanguageCodes = new string[] { "fin" };// default language is "eng"
    List<Subtitle> results = downloader.SearchSubtitles(query); // return English subtitles for "Heroes" season 1 episode 3;
    Saving subtitles
    Code:
    ISubtitlesDownloader downloader = new OpenSubtitlesDownloader();
    
    // Perform search
    List<Subtitle> results = ...
    
    // Download & save
    Subtitle subtitle = results[0];
    List<FileInfo> subtitleFiles = downloader.SaveSubtitle(subtitle);
    FileInfo subtitleFile = subtitleFiles[0];
    
    string videoFileName = "C:\Heroes.S04E03.720p.HDTV.X264-DIMENSION.avi";
    string targetSubtitleFile = FileUtils.GetFileNameForSubtitle(subtitleFile.FileName, subtitle.LanguageCode, videoFileName);
    
    // targetSubtitleFile is now "C:\Heroes.S04E03.720p.HDTV.X264-DIMENSION.English.srt"
    // if targetSubtitleFile exists, dialog for overwrite
    File.Move(subtitleFileName.FullName, targetSubtitleFile);
     
    Last edited:

    1stdead

    Portal Pro
    February 1, 2008
    1,089
    139
    Copenhagen
    Denmark Denmark
    Cool. I know this might be difficult. But why not adding subscene.com? Most subtitles are released here. Unfortunately you can't use hash"codes" only name. Series might be hard to filter also. But i think that would be great.
    Tvsubtitles is great for series(MPTVseries currently uses it)
    maybe Moviesubtitles.org - Download latest DivX/Xvid movies subtitles is worth considering as well?

    But really great work i must say. Remember to talk to the devs :)
     

    kgk

    Portal Member
    October 31, 2006
    27
    2
    Netherlands Netherlands
    OMG! Yay!. This sound awsome. Thank you for doing the work on this. Hopefully this will lead to much better and more robust auto subtitle download feature .
     

    seco

    Development Group
  • Team MediaPortal
  • August 7, 2007
    1,580
    1,236
    Finland Finland
    Country flag
    • Thread starter
    • Moderator
    • #6
    Yes, of course. SubtitleDownloader is an independent library which can be used in any C# program to find subtitles for TV series, movies etc.

    As I said in the first post, "The idea is that this library could be used by both My TVSeries and Moving Pictures in the near future."
     

    rasmuskarlsen

    Portal Pro
    October 9, 2008
    235
    12
    Denmark Denmark
    Yes, of course. SubtitleDownloader is an independent library which can be used in any C# program to find subtitles for TV series, movies etc.

    As I said in the first post, "The idea is that this library could be used by both My TVSeries and Moving Pictures in the near future."
    Sounds really nice... When do yuo think it would be ready for using it with movies!?
     

    seco

    Development Group
  • Team MediaPortal
  • August 7, 2007
    1,580
    1,236
    Finland Finland
    Country flag
    • Thread starter
    • Moderator
    • #8
    I'm currently finishing v0.3 up which is more suitable for movies. After this, there should be no more changes to API.

    In v0.3 movie subtitles can be queried by IMDB ID (already supported in v0.2):

    Code:
    ISubtitlesDownloader downloader = new SubtitleSourceDownloaderV2();
    ImdbSearchQuery query = new ImdbSearchQuery("0372784");
    List<Subtitle> results = new List<Subtitle>();
    results = downloader.SearchSubtitles(query);              // return subtitles for "Batman Begins"
    or by query string and optionally a year:

    Code:
    ISubtitlesDownloader downloader = new OpenSubtitlesDownloader();
    SearchQuery query = new SearchQuery("batman");
    query.Year = "2005";
    List<Subtitle> results = new List<Subtitle>();
    results = downloader.SearchSubtitles(query);              // return subtitles for "Batman Begins"
     

    rasmuskarlsen

    Portal Pro
    October 9, 2008
    235
    12
    Denmark Denmark
    Which site does your plugin get subtitles from!?

    Because i have allready tried: vroksub - Project Hosting on Google Code

    And it's getting from Opensibtitles.org, and that site isn't one of the best :/ Ex. Subscene is way much better, and holds many more subtitles for movies.. Ex, if i use Opensubtitles.org i can aprox get 5/10 subtitles downloaded (In combination between english and my native language), but if i use Subscene.com, i can aprox get 9/10 downloaded :)
     

    Users Who Are Viewing This Thread (Users: 0, Guests: 2)

    OP Similar threads Forum Replies Date
    doskabouter [Question] SubtitleDownloader Developer Discussions 56
    Similar threads

    Top Bottom