Skip to content

Commit

Permalink
JSON imports and namespace fixes (#32)
Browse files Browse the repository at this point in the history
* Added load from JSON function

* Namespace Fixes

* Fixes for namespaces 2

* We need requests!
  • Loading branch information
Emersont1 authored Apr 24, 2022
1 parent c6d3aa7 commit fb9391d
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 7 deletions.
5 changes: 2 additions & 3 deletions hstp/audioboom/channel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from audioboom import *
import audioboom
import audioboom.utils as utils
from hstp.audioboom import *
import hstp.audioboom.utils as utils

from os.path import join, exists, relpath
from os import mkdir
Expand Down
4 changes: 2 additions & 2 deletions hstp/audioboom/downloader/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import argparse

import audioboom
from hstp.audioboom import channel


def main():
Expand All @@ -16,7 +16,7 @@ def main():

args = parser.parse_args()

c = audioboom.Channel(args.id)
c = Channel(args.id)

c.get_episodes()
c.get_playlists()
Expand Down
2 changes: 1 addition & 1 deletion hstp/audioboom/structures.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json

from audioboom import utils
from hstp.audioboom import utils


class Episode:
Expand Down
15 changes: 15 additions & 0 deletions hstp/episode.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@
class Episode:
""" Class containing the information for a single podcast episode"""

@classmethod
def load(cls, info, data):
""" Loads an episode from a dict """
e = cls(
info,
name=data["name"],
slug=data["slug"],
description=data["description"],
date=datetime.strptime(data["date"], "%Y-%m-%dT%H:%M:%S"),
file=data["file"],
thumb=data["thumb"]
)

return e

def __init__(self, info, name, slug, description, date, file, thumb=None):
self.info = info

Expand Down
18 changes: 18 additions & 0 deletions hstp/podcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@


class Podcast:

@classmethod
def load(cls, info, data):
""" Loads a podcast from a dict """
p = cls(
info,
name=data["name"],
slug=data["slug"],
description=data["description"],
links=data["links"]
)

if "episodes" in data:
for e in data["episodes"]:
p.add_episode(Episode.load(info, e))

return p

def __init__(self, info, name, slug, description, thumb, links=None):
self.info = info

Expand Down
80 changes: 79 additions & 1 deletion poetry.lock

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

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pep8 = "1.7.1"
pycodestyle = "2.7.0"
python-dateutil = "2.8.2"
simple-colors = "0.1.5"
requests = "^2.27.1"

[tool.poetry.dev-dependencies]

Expand Down

0 comments on commit fb9391d

Please sign in to comment.