async def example_site_rip(date=None): """ Please, dont do this.. """ nrk = NRK() all_programs = await nrk.site_rip() for media in all_programs: if media.type == 'serie': for serie in await media.episodes(): await serie.download() else: await media.download()
async def example_search(): nrk = NRK() search_results = await nrk.search('Brannman Sam') for search in search_results: for season in search.seasons(): for episode in await season.episodes(): await episode.download() episode.subtitle() print('We found %s episodes to download' % len(nrk.downloads())) nrk.dry_run = True await nrk.downloads().start()
def test_expires_at(f, *args): n = NRK(dry_run=True) today = datetime.datetime.now() d_today = today.strftime('%d.%m.%Y') f_day = datetime.timedelta(weeks=4 * 3) fut = today + f_day ds = '%s-%s' % (d_today, fut.strftime('%d.%m.%Y')) with mock.patch(ips, side_effect=['::', 'y']): n.expires_at(ds) assert len(n.downloads())
def main(): NRK = NRK(gui=True) parser = GooeyParser() parser.add_argument('-u', '--url', action='store', default=False, required=False, widget='TextField', help='"url1 url2 url3"') parser.add_argument('-e', '--encoding', default='latin-1', required=False, help='Set encoding') parser.add_argument('-save', '--save_path', default=False, required=False, help='Download to this folder', widget='DirChooser') parser.add_argument('-dr', '--dry_run', action='store_true', default=False, required=False, help='Dry run, dont download anything') parser.add_argument('-v', '--verbose', action='store_true', default=False, required=False, help='Show ffmpeg output') parser.add_argument('-w', '--workers', default=2, required=False, help='Number of thread pool workers') parser.add_argument('-st', '--subtitle', action='store_true', default=False, required=False, help='Download subtitle for this media file?') parser.add_argument('-if', '--input_file', default=False, required=False, help='List of files to download', widget='FileChooser') p = parser.parse_args() NRK.dry_run = p.dry_run NRK.verbose = p.verbose NRK.subtitle = p.subtitle NRK.cli = False NRK.encoding = p.encoding NRK.workers = int(p.workers) if p.save_path: NRK.SAVE_PATH = p.save_path if p.input_file: NRK._from_file(p.input_file) if p.url: NRK.parse_url(p.url)
import datetime import sys from os.path import basename, getsize, split import mock import pytest from nrkdl import NRK import nrkdl from utils import c_out, parse_datestring, which, ppatch # We dont want to download ANY files nrk = NRK(dry_run=True, encoding='utf-8', workers=100) if sys.version_info >= (3, 0): PY3 = True ips = 'builtins.input' else: PY3 = False ips = '__builtin__.raw_input' def q_clear(): def outer(func): def inner(*args, **kwargs): try: func(*args, **kwargs) finally:
def example_parse_url(): # This starts downloading right away NRK().parse_urls('https://tv.nrk.no/serie/skam/MYNT15001016/sesong-2/episode-10 http://tv.nrksuper.no/serie/lili/MSUI28008314/sesong-1/episode-3')