Skip to content

Commit e8ee72a

Browse files
committed
Fix executable downloads, add PyPi workflow
1 parent 4a28dc1 commit e8ee72a

File tree

3 files changed

+68
-3
lines changed

3 files changed

+68
-3
lines changed

.github/workflows/pypi-publish.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- 'V*.*.*'
7+
8+
jobs:
9+
build-and-publish:
10+
runs-on: ubuntu-22.04
11+
permissions:
12+
contents: read
13+
id-token: write # needed for trusted publishing
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: '3.11'
23+
24+
- name: Install build tools
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install build
28+
29+
- name: Build package
30+
run: python -m build
31+
32+
- name: Publish to PyPI
33+
uses: pypa/gh-action-pypi-publish@release/v1

AFHscraper.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from bs4 import BeautifulSoup
33
import re
44
import os
5+
import sys
56
import time
67
from pathlib import Path
78
from urllib.parse import quote_plus
@@ -303,10 +304,17 @@ def main():
303304
mirror_choice = input("Enter choice (1 or 2): ").strip()
304305
mirror_pref = "Germany" if mirror_choice == '2' else "USA"
305306

306-
# Initialize scraper
307-
307+
# First, determine the correct path
308+
if getattr(sys, 'frozen', False):
309+
# Running as compiled executable
310+
download_dir = os.path.dirname(sys.executable)
311+
else:
312+
# Running as script
313+
download_dir = os.path.dirname(os.path.abspath(__file__))
314+
315+
# pass the resulting variable to the function
308316
scraper = AFHScraper(
309-
download_dir=os.path.dirname(os.path.abspath(__file__)),
317+
download_dir=download_dir,
310318
mirror_preference=mirror_pref
311319
)
312320

pyproject.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[build-system]
2+
requires = ["setuptools>=69.0.0", "wheel>=0.43.0"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "AndroidFileHostScraper"
7+
version = "1.0.1"
8+
description = "A simple AndroidFileHost scraper for fetching links and metadata."
9+
readme = "README.md"
10+
license = { text = "Apache-2.0" }
11+
authors = [
12+
{ name = "fl0w", email = "fl0w_dev@protonmail.com" }
13+
]
14+
requires-python = ">=3.8"
15+
dependencies = [
16+
"requests>=2.31.0",
17+
"beautifulsoup4>=4.12.3"
18+
]
19+
20+
[project.urls]
21+
Homepage = "https://github.com/codefl0w/AndroidFileHostScraper"
22+
Repository = "https://github.com/codefl0w/AndroidFileHostScraper"
23+
Issues = "https://github.com/codefl0w/AndroidFileHostScraper/issues"
24+
Donate = "https://buymeacoffee.com/fl0w"

0 commit comments

Comments
 (0)