def test_16p_last_page(scribd): URL = 'https://www.scribd.com/document/106884805/Nebraska-Wing-Sep-2012' PAGES = '16' scribd.download(URL, pages=PAGES) doc_id = re.search(r'(?P<id>\d+)', URL).group('id') saved_file = '{}-{}.pdf'.format(scribd._edit_title(scribd.doc_titles[-1]), doc_id) if saved_file in os.listdir() and get_modified_time_diff(saved_file) < 10: assert True else: assert False
def test_6p_whole(scribd): URL = 'https://www.scribd.com/document/374470199/INVITATION-pdf' scribd._set_pages(None) scribd.download(URL) doc_id = re.search(r'(?P<id>\d+)', URL).group('id') saved_file = '{}-{}.pdf'.format(scribd._edit_title(scribd.doc_titles[-1]), doc_id) if saved_file in os.listdir() and get_modified_time_diff(saved_file) < 10: assert True else: assert False
def test_78p_long_title_first_page(scribd): URL = 'https://www.scribd.com/document/352506425/Hydroponic-Green-House-Farming-Detailed-Project-Report-' \ 'Profile-Business-Plan-Industry-Trends-Market-Research-Survey-Raw-Materials-Feasibility-S' PAGES = '1' scribd.download(URL, PAGES) doc_id = re.search(r'(?P<id>\d+)', URL).group('id') saved_file = '{}-{}.pdf'.format(scribd._edit_title(scribd.doc_titles[-1]), doc_id) if saved_file in os.listdir() and get_modified_time_diff(saved_file) < 10: assert True else: assert False
def test_1p_random_document(scribd): URL = generate_random_document() PAGES = '1' try: scribd.download(URL, PAGES) except RestrictedDocumentError: assert True else: doc_id = re.search(r'(?P<id>\d+)', URL).group('id') saved_file = '{}-{}.pdf'.format(scribd._edit_title(scribd.doc_titles[-1]), doc_id) if saved_file in os.listdir() and get_modified_time_diff(saved_file) < 10: assert True else: assert False
def test_context_manager(): URLS = ['https://www.scribd.com/document/352366744/', 'https://www.scribd.com/document/351688288/'] with ScribdDL() as session: session.download(URLS[0], pages='1-3') session.download(URLS[1], pages='3-5') saved_files = [] doc_id = re.search(r'(?P<id>\d+)', URLS[0]).group('id') saved_files.append('{}-{}.pdf'.format(session._edit_title(session.doc_titles[0]), doc_id)) doc_id = re.search(r'(?P<id>\d+)', URLS[1]).group('id') saved_files.append('{}-{}.pdf'.format(session._edit_title(session.doc_titles[1]), doc_id)) for f in saved_files: if f in os.listdir() and get_modified_time_diff(f) < 60: assert True else: assert False