aboutsummaryrefslogtreecommitdiff
path: root/tests.lua
blob: 5520bcb95f4c654048292fde678b5e8486ecaca5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env lua

local opensubtitles = require 'server.opensubtitles'

local note = function (success, name)
    local sign

    if success then
        sign = '✅'
    else
        sign = '❌'
    end

    print(sign .. ' : ' .. name)
end


local test_opensubtitles = function ()
    local ohash, name, id

    ohash = '395787dbe5b42001'
    name = 'Fight.Club.1999.REMASTERED.720p.BRRip.XviD.AC3-RARBG'
    id = opensubtitles.search_ohash(ohash, name, 'eng')
    note(id and id:match('%d+$') == '5449593', 'search_ohash')

    name = 'Fight.Club.10th.Anniversary.Edition.1999.720p.BrRip.x264.YIFY'
    id = opensubtitles.search_filesize(1074575924, name, 'eng')
    note(id and id:match('%d+$') == '4987774', 'search_filesize')

    name = 'Fight.Club.1999.REMASTERED.720p.BRRip.XviD.AC3-RARBG'
    id = opensubtitles.search_name(name, 'eng')
    note(id and id:match('%d+$') ==  '5449593', 'search_name')
end

test_opensubtitles()