Esempio n. 1
0
def _construct_download_item(wanted_item, subtitles, language, single):
    log.debug('Constructing the download item')

    # Get the subtitle, subtitles should only contain 1 subtitle
    subtitle = subtitles[0]
    log.debug('Download page link: %s', subtitle.page_link)

    # Construct the download item
    download_item = DownloadItem(wanted_item)
    subtitle_path = subliminal.subtitle.get_subtitle_path(download_item.video.name, None if single else language)
    download_item.subtitlepath = subtitle_path
    download_item.downloadLink = subtitle.page_link
    download_item.downlang = text_type(language)  # return alpha2 (f.e. 'nl') or ietf code (f.e. 'pt-BR')
    download_item.subtitle = os.path.split(download_item.subtitlepath)[1][:-4]
    download_item.provider = subtitle.provider_name
    download_item.subtitles = subtitles
    download_item.single = single

    return download_item
Esempio n. 2
0
# coding=utf-8

from autosubliminal.core.item import DownloadItem, WantedItem
from autosubliminal.notifiers.pushbullet import PushbulletNotifier

notifier_name = 'Pushbullet'

download_item = DownloadItem(WantedItem())
download_item.videopath = 'path/to/video'
download_item.subtitlepath = 'path/to/subtitle'
download_item.downlang = 'en'
download_item.provider = 'provider'


def test_pushbullet_disabled():
    notifier = PushbulletNotifier()
    assert notifier.name == notifier_name
    assert notifier.notify('test') is False
    assert notifier.notify_download(download_item) is False


def test_pushbullet_exception(monkeypatch):
    monkeypatch.setattr('autosubliminal.NOTIFYPUSHBULLET', True)
    monkeypatch.setattr('autosubliminal.PUSHBULLETAPI',
                        '123456')  # Invalid api key
    notifier = PushbulletNotifier()
    assert notifier.name == notifier_name
    assert notifier.notify('test') is False
    assert notifier.notify_download(download_item) is False

Esempio n. 3
0
# coding=utf-8

from autosubliminal.core.item import DownloadItem, WantedItem
from autosubliminal.notifiers.growl import GrowlNotifier

notifier_name = 'Growl'

download_item = DownloadItem(WantedItem())
download_item.videopath = 'path/to/video'
download_item.subtitlepath = 'path/to/subtitle'
download_item.downlang = 'en'
download_item.provider = 'provider'


def test_growl_disabled():
    notifier = GrowlNotifier()
    assert notifier.name == notifier_name
    assert notifier.notify('test') is False
    assert notifier.notify_download(download_item) is False


def test_growl_error(monkeypatch, mocker):
    monkeypatch.setattr('autosubliminal.NOTIFYGROWL', True)
    monkeypatch.setattr('autosubliminal.GROWLHOST', 'localhost')
    monkeypatch.setattr('autosubliminal.GROWLPORT', 23053)
    mocker.patch('gntp.notifier.GrowlNotifier.notify', return_value=False)
    notifier = GrowlNotifier()
    assert notifier.name == notifier_name
    assert notifier.notify('test') is False
    assert notifier.notify_download(download_item) is False