umpaper-fetch 1.0.0__py3-none-any.whl → 1.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- umpaper_fetch/__init__.py +1 -1
- umpaper_fetch/cli.py +36 -2
- umpaper_fetch/utils/zip_creator.py +2 -2
- {umpaper_fetch-1.0.0.dist-info → umpaper_fetch-1.0.1.dist-info}/METADATA +1 -1
- {umpaper_fetch-1.0.0.dist-info → umpaper_fetch-1.0.1.dist-info}/RECORD +9 -9
- {umpaper_fetch-1.0.0.dist-info → umpaper_fetch-1.0.1.dist-info}/WHEEL +0 -0
- {umpaper_fetch-1.0.0.dist-info → umpaper_fetch-1.0.1.dist-info}/entry_points.txt +0 -0
- {umpaper_fetch-1.0.0.dist-info → umpaper_fetch-1.0.1.dist-info}/licenses/LICENSE +0 -0
- {umpaper_fetch-1.0.0.dist-info → umpaper_fetch-1.0.1.dist-info}/top_level.txt +0 -0
umpaper_fetch/__init__.py
CHANGED
@@ -5,7 +5,7 @@ This package provides tools to automatically download past year exam papers
|
|
5
5
|
from University Malaya's repository through an automated browser interface.
|
6
6
|
"""
|
7
7
|
|
8
|
-
__version__ = "1.0.
|
8
|
+
__version__ = "1.0.1"
|
9
9
|
__author__ = "Marcus Mah"
|
10
10
|
__email__ = "marcusmah6969@gmail.com"
|
11
11
|
__description__ = "Automated downloader for University Malaya past year exam papers"
|
umpaper_fetch/cli.py
CHANGED
@@ -267,7 +267,24 @@ def main():
|
|
267
267
|
sys.exit(1)
|
268
268
|
|
269
269
|
logger.info(f"✅ Found {len(papers)} papers")
|
270
|
-
|
270
|
+
|
271
|
+
# Display found papers list
|
272
|
+
print(f"\n{'='*80}")
|
273
|
+
print(f"📄 FOUND {len(papers)} PAST YEAR PAPERS FOR {subject_code}")
|
274
|
+
print(f"{'='*80}")
|
275
|
+
for i, paper in enumerate(papers, 1):
|
276
|
+
print(f"{i:2d}. {paper['title']}")
|
277
|
+
print(f" 📅 Year: {paper['year']}, Semester: {paper['semester']}")
|
278
|
+
print(f" 📝 Type: {paper['paper_type']}")
|
279
|
+
print(f" 🔗 URL: {paper['pdf_url']}")
|
280
|
+
print()
|
281
|
+
|
282
|
+
# Ask user if they want to download all papers
|
283
|
+
download_confirm = input(f"Download all {len(papers)} papers? (y/N): ").strip().lower()
|
284
|
+
if download_confirm not in ['y', 'yes']:
|
285
|
+
print("❌ Download cancelled by user")
|
286
|
+
authenticator.cleanup()
|
287
|
+
sys.exit(0)
|
271
288
|
|
272
289
|
# Step 3: Download papers
|
273
290
|
logger.info("Step 3: Downloading papers...")
|
@@ -283,13 +300,30 @@ def main():
|
|
283
300
|
# Step 4: Create ZIP archive
|
284
301
|
logger.info("Step 4: Creating ZIP archive...")
|
285
302
|
zip_creator = ZipCreator()
|
286
|
-
|
303
|
+
zip_filename = f"{subject_code}_Past_Year_Papers.zip"
|
304
|
+
zip_path_full = output_dir / zip_filename
|
305
|
+
zip_path = zip_creator.create_zip(downloaded_files, str(zip_path_full), subject_code)
|
287
306
|
|
288
307
|
if zip_path:
|
289
308
|
logger.info(f"✅ ZIP archive created: {zip_path}")
|
290
309
|
print(f"\n🎉 Success! All papers downloaded and zipped:")
|
291
310
|
print(f"📦 ZIP file: {zip_path}")
|
292
311
|
print(f"📁 Individual files: {output_dir / subject_code}")
|
312
|
+
|
313
|
+
# Ask if user wants to delete individual files
|
314
|
+
print(f"\n📁 Individual PDF files are still in: {output_dir / subject_code}")
|
315
|
+
delete_confirm = input("Delete individual files to save space? (y/N): ").strip().lower()
|
316
|
+
if delete_confirm in ['y', 'yes']:
|
317
|
+
try:
|
318
|
+
import shutil
|
319
|
+
shutil.rmtree(output_dir / subject_code)
|
320
|
+
print("✅ Individual files deleted successfully")
|
321
|
+
logger.info("Individual files deleted by user request")
|
322
|
+
except Exception as e:
|
323
|
+
print(f"⚠️ Failed to delete individual files: {e}")
|
324
|
+
logger.warning(f"Failed to delete individual files: {e}")
|
325
|
+
else:
|
326
|
+
print("📁 Individual files kept")
|
293
327
|
else:
|
294
328
|
logger.warning("⚠️ ZIP creation failed, but individual files are available")
|
295
329
|
print(f"\n⚠️ Papers downloaded but ZIP creation failed")
|
@@ -99,7 +99,7 @@ class ZipCreator:
|
|
99
99
|
'year': year,
|
100
100
|
'semester': semester,
|
101
101
|
'paper_type': paper_type,
|
102
|
-
'original_name': filename
|
102
|
+
'original_name': str(filename)
|
103
103
|
}
|
104
104
|
|
105
105
|
return organized
|
@@ -133,7 +133,7 @@ class ZipCreator:
|
|
133
133
|
filename = file_info.get('original_name', file_path.name)
|
134
134
|
path_parts.append(filename)
|
135
135
|
|
136
|
-
return '/'.join(path_parts)
|
136
|
+
return '/'.join(str(part) for part in path_parts)
|
137
137
|
|
138
138
|
def _extract_year_from_filename(self, filename):
|
139
139
|
"""Extract year from filename."""
|
@@ -5,8 +5,8 @@ downloader/__init__.py,sha256=Qq3Oex541SjsJBe4Tx2lR7BjCHbPZaGGAscWaU3gUB4,21
|
|
5
5
|
downloader/pdf_downloader.py,sha256=5g9_suFe6rG7Vjny7gScRkCSVPiYxKwB7NH8PTPR2Z0,7957
|
6
6
|
scraper/__init__.py,sha256=cNGEi--R5BTUOwpnANA2BsR2yfnmG9qrwagEOtzI0E4,18
|
7
7
|
scraper/paper_scraper.py,sha256=NNnJ6eFxgueJfYwZFbTbsnxMAUUbIM0A72q0QNubaVk,12970
|
8
|
-
umpaper_fetch/__init__.py,sha256=
|
9
|
-
umpaper_fetch/cli.py,sha256=
|
8
|
+
umpaper_fetch/__init__.py,sha256=Xs37vDkvGGw5O4hhSQfLyMf3QQAFMZ0Elx8ZFMr-2To,830
|
9
|
+
umpaper_fetch/cli.py,sha256=HoZbiU7OLbXjcJwUoSoKj5jJi_VAFFPT4q2pkfUkY2o,12445
|
10
10
|
umpaper_fetch/auth/__init__.py,sha256=AMRDJpqoFyQt3kcRcihx7LMAIFmWeJe_wfy-i4JyUXs,25
|
11
11
|
umpaper_fetch/auth/chrome_fix.py,sha256=sSTvUIWLme5e-raXCM_AJ2IkK3PHSrxNv_g7itSolkg,3828
|
12
12
|
umpaper_fetch/auth/um_authenticator.py,sha256=Rii9E6-2MvE_orcMW4u93tSY8QaT21P_HJeJPExDUzQ,24165
|
@@ -16,13 +16,13 @@ umpaper_fetch/scraper/__init__.py,sha256=cNGEi--R5BTUOwpnANA2BsR2yfnmG9qrwagEOtz
|
|
16
16
|
umpaper_fetch/scraper/paper_scraper.py,sha256=NNnJ6eFxgueJfYwZFbTbsnxMAUUbIM0A72q0QNubaVk,12970
|
17
17
|
umpaper_fetch/utils/__init__.py,sha256=oukU0ufroPRd8_N8d2xiFes9CTxSaw4NA6p2nS1kkSg,16
|
18
18
|
umpaper_fetch/utils/logger.py,sha256=LJhnN3KoAB9bX4BdfK6bk2urnQEVwG1FFlOeFGbVg7U,2098
|
19
|
-
umpaper_fetch/utils/zip_creator.py,sha256=
|
20
|
-
umpaper_fetch-1.0.
|
19
|
+
umpaper_fetch/utils/zip_creator.py,sha256=44dnsMdJRvOktjl4ajDqaxTiYfznbkERzzpcnGogS5I,10731
|
20
|
+
umpaper_fetch-1.0.1.dist-info/licenses/LICENSE,sha256=bwdpp_9mjxdcCEY-7f8XVEQDoyImNLNDUtYGezKFbFk,1113
|
21
21
|
utils/__init__.py,sha256=oukU0ufroPRd8_N8d2xiFes9CTxSaw4NA6p2nS1kkSg,16
|
22
22
|
utils/logger.py,sha256=LJhnN3KoAB9bX4BdfK6bk2urnQEVwG1FFlOeFGbVg7U,2098
|
23
23
|
utils/zip_creator.py,sha256=Mr5rT52vEyNQJB0Cg99r6QTNJBnzqGnnqd3wPK4uaxY,10704
|
24
|
-
umpaper_fetch-1.0.
|
25
|
-
umpaper_fetch-1.0.
|
26
|
-
umpaper_fetch-1.0.
|
27
|
-
umpaper_fetch-1.0.
|
28
|
-
umpaper_fetch-1.0.
|
24
|
+
umpaper_fetch-1.0.1.dist-info/METADATA,sha256=UlokHjM9F946ThPCl9Qhhhv-_Z6LC-2q36eanFudxew,15372
|
25
|
+
umpaper_fetch-1.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
26
|
+
umpaper_fetch-1.0.1.dist-info/entry_points.txt,sha256=8XnqR8M2yO02n6DcUdJXoSVpgBG4TvaSRNBqi4A_XcQ,53
|
27
|
+
umpaper_fetch-1.0.1.dist-info/top_level.txt,sha256=NU9S9Nnj8CJvOZvkoKbicMNk0apwlHJjdL6yjU7pnWs,44
|
28
|
+
umpaper_fetch-1.0.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|