Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/pipenv #7

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
lxml = "4.8"
tqdm = "4.64"
feedparser = "6.0.10"
requests = "2.27.1"
argparse = "1.4"

[dev-packages]

[requires]
python_version = "3.10"
158 changes: 158 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 40 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,52 @@ file with the same name as the episode audio, with `.txt` appended.

<a name="footnote1">1</a>: Only \~100 lines of Python!

<a name="footnote2">2</a>: *Probably*, I've only tested on Mac.
<a name="footnote2">2</a>: *Probably*, this has only been tested on Mac and Linux (Pop\!\_os 22.04).

## Usage

### Python

```bash
python podsnatch.py --opml <input file> -o <output directory>
```

### Pipenv

You can also use Python Pipenv to create and use virtual environments to keep your
Python installation clean. Once `pip` is installed, run the following command to
install `pipenv`:

```bash
pip install pipenv
```

Once `pipenv` is installed, install the required packages from `Pipfile.lock`:

```bash
pipenv sync
```

To install newer versions of packages, edit `Pipfile` to the desired version then run:

```bash
pipenv update
```

To run the `podsnatch.py` script, run:

```bash
pipenv run python podsnatch.py --opml <input file> -o <output directory>
```

The `requirements.txt` can be updated based on what's in `Pipefile` by running:

```bash
pipenv requirements > requirements.txt
```

### Docker

If you don't want to deal with all the python setup crap (and I don't blame you)
you can build the docker container and run with

Expand Down
11 changes: 6 additions & 5 deletions podsnatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class Show:

def __init__(self, outline_element):
self.title = outline_element.get('title')
self.title = outline_element.get('text')
self.url = (outline_element.get('xmlUrl') or
outline_element.get('xmlurl') or
None)
Expand All @@ -41,14 +41,15 @@ def __init__(self, item, show):
self.number = item.itunes_episode if 'itunes_episode' in item else ''
self.url = item.enclosures[0].href if 'enclosures' in item and item.enclosures else ''
self.date = item.published_parsed if 'published_parsed' in item else ''
self.date_text = item.published if 'published' in item else ''

self.show = show

def __str__(self):
return f"""{self.title}
{self.number}
{self.guid}
{self.date}
{self.date_text}
{self.link}
{self.url}
{self.content if self.content else self.description}
Expand All @@ -64,8 +65,8 @@ def get_file_name(self):
return '_'.join([s for s in name_tokens if s is not ''])


def parse_ompl(ompl_path):
tree = xml.parse(ompl_path)
def parse_opml(opml_path):
tree = xml.parse(opml_path)
root = tree.getroot()

shows = root.findall('./body/outline')
Expand Down Expand Up @@ -98,7 +99,7 @@ def save_podcasts(opml, output, episode_count=None):
global total_downloaded
global full_path

shows = parse_ompl(opml)
shows = parse_opml(opml)

for show in shows:
print(f'Processing show {show.title}')
Expand Down
15 changes: 11 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
feedparser==5.2.1
lxml==4.6.5
requests==2.22.0
tqdm==4.39.0
-i https://pypi.org/simple
argparse==1.4.0
certifi==2022.5.18.1
charset-normalizer==2.0.12
feedparser==6.0.10
idna==3.3
lxml==4.8.0
requests==2.27.1
sgmllib3k==1.0.0
tqdm==4.64.0
urllib3==1.26.9