Skip to content

Commit

Permalink
Update v1.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkHershey committed Sep 15, 2023
1 parent 3851fb9 commit 317ecee
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 8 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.3
1.1.4
2 changes: 2 additions & 0 deletions arxiv_dl/arxiv_dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
scrape_metadata_nips,
scrape_metadata_openreview,
)
from .updater import check_update


def main(
Expand All @@ -38,6 +39,7 @@ def main(
Download paper and extract paper metadata
"""

### Get Target Download Directory
try:
if download_dir is None:
Expand Down
3 changes: 3 additions & 0 deletions arxiv_dl/bin/arxiv-dl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import argparse

from arxiv_dl.arxiv_dl import main
from arxiv_dl.updater import check_update

parser = argparse.ArgumentParser()
parser.add_argument(
Expand Down Expand Up @@ -41,6 +42,8 @@ args = parser.parse_args()

urls = args.urls

check_update()

for i, url in enumerate(urls):
print(f"[{i+1}/{len(urls)}] >>> {url}")
try:
Expand Down
3 changes: 3 additions & 0 deletions arxiv_dl/bin/getpaper
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import argparse

from arxiv_dl.arxiv_dl import main
from arxiv_dl.updater import check_update

parser = argparse.ArgumentParser()
parser.add_argument(
Expand Down Expand Up @@ -41,6 +42,8 @@ args = parser.parse_args()

urls = args.urls

check_update()

for i, url in enumerate(urls):
print(f"[{i+1}/{len(urls)}] >>> {url}")
try:
Expand Down
3 changes: 3 additions & 0 deletions arxiv_dl/bin/paper
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import argparse

from arxiv_dl.arxiv_dl import main
from arxiv_dl.updater import check_update

parser = argparse.ArgumentParser()
parser.add_argument(
Expand Down Expand Up @@ -41,6 +42,8 @@ args = parser.parse_args()

urls = args.urls

check_update()

for i, url in enumerate(urls):
print(f"[{i+1}/{len(urls)}] >>> {url}")
try:
Expand Down
15 changes: 9 additions & 6 deletions arxiv_dl/helpers.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import json
import logging
import os
import pypdf
import re
import shlex
import string
import subprocess
from pathlib import Path
from typing import Union

import pypdf

from .dl_utils import download
from .logger import logger
from .models import PaperData
Expand Down Expand Up @@ -196,11 +197,13 @@ def add_pdf_metadata(paper_data: PaperData, download_path: Path):
writer.add_metadata(metadata)

# Add the new metadata
writer.add_metadata({
"/Author": ", ".join(paper_data.authors),
"/Title": paper_data.title,
"/Subject": paper_data.abstract,
})
writer.add_metadata(
{
"/Author": ", ".join(paper_data.authors),
"/Title": paper_data.title,
"/Subject": paper_data.abstract,
}
)

# Save the new PDF to a file
with open(download_path, "wb") as f:
Expand Down
39 changes: 39 additions & 0 deletions arxiv_dl/updater.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import json

import pkg_resources
import requests


def check_latest_version():
"""Check the latest version of arxiv-dl on PyPI."""
pypi_url = "https://pypi.org/pypi/arxiv-dl/json"
response = requests.get(pypi_url)
if response.status_code == 200:
pypi_data = response.text
pypi_data = json.loads(pypi_data)
latest_version = pypi_data.get("info", {}).get("version", "")
else:
latest_version = ""
return latest_version


def check_current_version():
"""Check the current version of arxiv-dl."""
current_version = pkg_resources.get_distribution("arxiv-dl").version
return current_version


def check_update():
"""Remind user to update arxiv-dl if there is a new version."""
latest_version = check_latest_version()
current_version = check_current_version()
print(f"[arxiv-dl] (version: {current_version})")

if latest_version and latest_version != current_version:
print(
f"[arxiv-dl] latest version available: {latest_version}. You may update by running: pip install --upgrade arxiv-dl"
)


if __name__ == "__main__":
check_update()
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

MAJOR = 1
MINOR = 1
MICRO = 3
MICRO = 4
VERSION = "%d.%d.%d" % (MAJOR, MINOR, MICRO)


Expand Down

0 comments on commit 317ecee

Please sign in to comment.