GithubHelp home page GithubHelp logo

alexanderwink / subdl Goto Github PK

View Code? Open in Web Editor NEW
85.0 85.0 18.0 73 KB

subdl - command-line tool to download subtitles from opensubtitles.org Official support for subdl seems to have been dropped. This site is intended for the future use of subdl with community driven support.

Python 100.00%

subdl's People

Contributors

alexanderwink avatar buzz avatar fbarthelery avatar franciscoromao avatar gabrielsimoes avatar geoffrey-a avatar leonid99 avatar mek-apelsin avatar meyer1994 avatar milahu avatar psychoraz avatar rnbguy avatar whynothugo avatar xificurc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

subdl's Issues

subdl --list-languages no longer works

subdl --version
subdl 1.1.2
subdl --list-languages
Traceback (most recent call last):
  File "/usr/local/bin/subdl", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/usr/local/lib/python3.11/site-packages/subdl.py", line 534, in cli
    main(sys.argv[1:])
  File "/usr/local/lib/python3.11/site-packages/subdl.py", line 459, in main
    files = parseargs(args)
            ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/subdl.py", line 444, in parseargs
    ListLanguages()
  File "/usr/local/lib/python3.11/site-packages/subdl.py", line 358, in ListLanguages
    languages = xmlrpc_server.GetSubLanguages('')['data']
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'GetSubLanguages'

utf8 option fails to convert some subtitles

$ alias subdl='subdl --utf8 --download=all --existing=bypass --force-filename --username=xx --password=xx'

$ subdl Irreversible.2002.mp4 
Searching for subtitles for query=Irreversible.2002...
Found 24 results for 'Irreversible.2002.mp4':
#1952041941 [en] [Rat: 0.0 DL:70016] "Irreversible" Irreversible.2002.DVDRip.XviD.AC3-DK.EN.srt 
[...]
Found encoding Johab with a confidence of 99.00%. Converting to utf8.
Downloading #1952041941 to Irreversible.2002.en.1952041941.srt... Traceback (most recent call last):
  File ".subdl-wrapped", line 9, in <module>
    sys.exit(cli())
  File "subdl.py", line 534, in cli
    main(sys.argv[1:])
  File "subdl.py", line 504, in main
    AutoDownloadAndSave(file, search_result, downloaded)
  File "subdl.py", line 339, in AutoDownloadAndSave
    DownloadAndSaveSubtitle(search_result.IDSubtitleFile, output_filename)
  File "subdl.py", line 315, in DownloadAndSaveSubtitle
    s = s.decode(result["encoding"]) # bytes -> str
UnicodeDecodeError: 'johab' codec can't decode byte 0xb4 in position 13235: illegal multibyte sequence

Irreversible.2002.DVDRip.XviD.AC3-DK.EN.srt
https://www.opensubtitles.org/en/subtitles/3431287/irreversible-en

cd $(mktemp -d)
sub_id=3431287
wget https://dl.opensubtitles.org/en/download/sub/$sub_id
unzip -B $sub_id
chardetect *.srt 
# Irreversible.2002.DVDRip.XviD.AC3-DK.EN.srt: Johab with confidence 0.99
iconv -f johab -t utf8 *.srt >/dev/null 
# iconv: illegal input sequence at position 13187
dd if=$(ls *.srt) bs=1 skip=$((13187 - 8)) count=16 status=none | hexdump -C
# 00000000  79 21 0d 0a 2d 20 57 65  b4 72 65 20 67 6f 69 6e  |y!..- We.re goin|

"johab" sounds weird. lets try latin1

iconv -f latin1 -t utf8 *.srt >/dev/null && echo ok
# ok

success! so its a bug in chardet ...

todo: workaround: when conversion to utf8 fails, keep the original file, show a warning, rename the result file to $basename.noutf8.$extension, for example Irreversible.2002.en.1952041941.noutf8.srt

api.opensubtitles.org will be deprecated on 2024-01-01

i just got this email

OpenSubtitles.org is undergoing a transformation, retiring the original API by the end of 2023

Exciting news! OpenSubtitles.org is undergoing a transformation, retiring the original API by the end of 2023. Fear not, as this paves the way for the advanced OpenSubtitles.com REST API. We also understand, in some scenarios there is no way to use new API yet, so original API will be available from New Year only for VIP Users.

so this will stop working in 7 weeks

subdl/subdl.py

Line 26 in 0ac57a8

OSDB_SERVER_URI = "https://api.opensubtitles.org/xml-rpc"

new api: https://www.opensubtitles.com/docs/api/html/index.htm

one nice thing about the move from .org to .com is that .com has all subtitles in utf8 encoding
it will be interesting, how many subs will be broken, because guessing the encoding is not trivial, see #37

Glob problem in Linux

I had problems downloading subtitles for a file containing '[' and ']' in the filename, because you are using the glob package on all arguments. I believe that at least on Unix-based operating systems you shouldn't apply glob to the arguments, since Unix shells already apply glob to the command lines.

Anyway, even on Windows it will fail when there are '[' or ']' on the filename.

Tag a release

Hi!
Any chance to have the latest release also tagged, so that the tarballs are created by github? That would be awesome!
Cheers!
J

Multiple filenames

First of all, thanks for your very useful program. I've been using it a lot.

I would like to suggest an option for adding more than one filename. It can be useful for downloading subtitles for tv series that comes in multiple files.

Search by movie name

When searching by filename in this case "Buster's Mal Heart (2017) BR-Rip AC3 6 [FGT].mkv" subdl finds no subtitle, but renaming the file to "Buster's Mal Heart" it does.

Maybe an option to download by movie name?

Thanks

Downloading only one language

Hello
When using "--lang=eng,pob" subdl downloads only the first subtitle found in the first language defined.

I always download subtitles in both languages so I need to run first "--lang=eng --output={m}.{L}.{S}" and then "--lang=pob --output={m}.{L}.{S}" to download in both langages

thanks

argparse

use argparse to parse arguments

currently, we must set options first

subdl --option movie.mkv

but this should work too

subdl movie.mkv --option

Support for post-processing (file encoding, file type)

I have tried multiple other solutions and this is the best one at this moment. My only gripe is that for some languages default format is most often txt (which some players acknowledge, but never auto-load) with pre-utf8 encoding (which requires separate tool to correct it) and right now, unlike competitors, subdl has no built-in option to correct these problems.

Also, being able to check file encoding could also help with (automatic) subtitle selection, since newer, more likely to be better subtitles don't use anything else than unicode.

If possible, I'd like to contribute at least a preliminary support for post-processing, but before I do that I'd like to know how should I attempt it.

add fuzzy search by movie name and year

problem: search is too narrow

example:

subdl --download=all Some.Movie.2022.720p.WEBRip.x264-SomeReleaser.mkv

this will not find other releases, with different resolution/codec/releaser/source/container/...

Some.Movie.2022.720p.WEBRip.x264-SomeReleaser.mkv # query

Some.Movie.2022.1080p.WEBRip.x264-SomeReleaser.mkv
Some.Movie.2022.720p.WEBRip.x265-SomeReleaser.mkv
Some.Movie.2022.720p.WEBRip.x264-OtherReleaser.mkv
Some.Movie.2022.720p.BluRay.x264-SomeReleaser.mkv
Some.Movie.2022.720p.WEBRip.x264-SomeReleaser.mp4
...

expected: also search by movie name and year (Some Movie 2022)

candidates

movie:

guessit Some.Movie.2022.720p.WEBRip.x264-SomeReleaser.mkv

For: Some.Movie.2022.720p.WEBRip.x264-SomeReleaser.mkv
GuessIt found: {
    "title": "Some Movie",
    "year": 2022,
    "screen_size": "720p",
    "source": "Web",
    "other": "Rip",
    "video_codec": "H.264",
    "release_group": "SomeReleaser",
    "container": "mkv",
    "mimetype": "video/x-matroska",
    "type": "movie"
}

episode:

guessit Some.Series.S01E01.720p.WEBRip.x264-SomeReleaser.mkv

For: Some.Series.S01E01.720p.WEBRip.x264-SomeReleaser.mkv
GuessIt found: {
    "title": "Some Series",
    "season": 1,
    "episode": 1,
    "screen_size": "720p",
    "source": "Web",
    "other": "Rip",
    "video_codec": "H.264",
    "release_group": "SomeReleaser",
    "container": "mkv",
    "mimetype": "video/x-matroska",
    "type": "episode"
}

Problem running

I am experiencing:

$ subdl my_file_name.mkv
Traceback (most recent call last):
  File "/usr/local/bin/subdl", line 6, in <module>
    from subdl import cli
  File "/usr/local/lib/python2.7/dist-packages/subdl.py", line 196
    print("Searching for subtitles for moviehash=%s..." % (moviehash), file=sys.stderr)
                                                                           ^
SyntaxError: invalid syntax

I guess either I am missing anything or there is something wrong

dlsubc file extension should be srt

actual vs expected

-Irreversible.2002.en.1952734608.dlsubc
+Irreversible.2002.en.1952734608.srt
$ head -n12 Irreversible.2002.en.1952734608.dlsubc
1
00:00:06,000 --> 00:00:12,074
Support us and become VIP member 
to remove all ads from www.OpenSubtitles.org

2
00:05:12,045 --> 00:05:14,216
You know what?

3
00:05:20,753 --> 00:05:23,231
Time destroys all things.

opensubtitles.org returns 401 on anonymous login

% python3 ~/subdl/subdl filename.mkv 
Traceback (most recent call last):
  File "/Users/leonid/subdl/subdl", line 70, in <module>
    osdb_token = login["token"]
KeyError: 'token'

I have added support for the username and password: #13
Please merge

default "search by movie hash" is too narrow

by default, subdl uses "search by movie hash" to find subtitles

problem: when i have a 720p release, it has a different movie hash than a 1080p release, so subdl finds less subtitles than expected

potential problem with "search by filename": abbreviated filenames like asdf.mp4. maybe change the default to "search by filename", and add a hybrid mode "search by filename and movie hash"

continue #31

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.