summaryrefslogtreecommitdiffstats
path: root/extra
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2021-06-11 15:13:39 -0700
committerBryan Newbold <bnewbold@archive.org>2021-06-11 15:13:39 -0700
commit6cad89bfbd343338137da604abc76a0e3fb23d8b (patch)
tree57a35e105892ab57ffaaa2449bc8ae0c77ed3c7f /extra
parent388eeaf4fa137522ec90c96e57581ced33205e57 (diff)
downloadfatcat-scholar-6cad89bfbd343338137da604abc76a0e3fb23d8b.tar.gz
fatcat-scholar-6cad89bfbd343338137da604abc76a0e3fb23d8b.zip
sitemap: new access URL format
Diffstat (limited to 'extra')
-rwxr-xr-xextra/sitemap/access_urls_query.sh2
-rwxr-xr-xextra/sitemap/transform_access_url.py11
2 files changed, 6 insertions, 7 deletions
diff --git a/extra/sitemap/access_urls_query.sh b/extra/sitemap/access_urls_query.sh
index eb34564..7f1c3ef 100755
--- a/extra/sitemap/access_urls_query.sh
+++ b/extra/sitemap/access_urls_query.sh
@@ -10,7 +10,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
# NOTE: filter out 12-digit access URLs (vs. 14-digit)
fatcat-cli search scholar 'doc_type:work (fulltext.access_type:ia_file OR fulltext.access_type:wayback) (NOT biblio.arxiv_id:*) (NOT biblio.pmcid:*) (NOT biblio.publisher_type:big5) (year:<1926 OR tags:*)' --index-json --limit 0 \
| pv -l \
- | jq '[.fulltext.access_type, .fulltext.access_url] | @tsv' -r \
+ | jq '[.work_ident, .fulltext.access_type, .fulltext.access_url] | @tsv' -r \
| rg -v '^null' \
| rg -v 'web.archive.org/web/\d{12}/' \
| $SCRIPT_DIR/transform_access_url.py \
diff --git a/extra/sitemap/transform_access_url.py b/extra/sitemap/transform_access_url.py
index b00bd82..5e12801 100755
--- a/extra/sitemap/transform_access_url.py
+++ b/extra/sitemap/transform_access_url.py
@@ -3,22 +3,21 @@
import sys
# NOTE: copied from fatcat_scholar/hacks.py
-def make_access_redirect_url(access_type: str, access_url: str) -> str:
+def make_access_redirect_url(work_ident: str, access_type: str, access_url: str) -> str:
if access_type == "wayback" and "://web.archive.org/" in access_url:
segments = access_url.split("/")
- dt = segments[4]
original_url = "/".join(segments[5:])
- return f"https://scholar.archive.org/access/wayback/{dt}/{original_url}"
+ return f"https://scholar.archive.org/work/{work_ident}/access/wayback/{original_url}"
elif access_type == "ia_file" and "://archive.org/download/" in access_url:
suffix = "/".join(access_url.split("/")[4:])
- return f"https://scholar.archive.org/access/ia_file/{suffix}"
+ return f"https://scholar.archive.org/work/{work_ident}/access/ia_file/{suffix}"
else:
return access_url
def run() -> None:
for line in sys.stdin:
- (access_type, access_url) = line.strip().split('\t')
- print(make_access_redirect_url(access_type, access_url))
+ (work_ident, access_type, access_url) = line.strip().split('\t')
+ print(make_access_redirect_url(work_ident, access_type, access_url))
if __name__ == "__main__":
run()