talklib 2.2.0__tar.gz → 3.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {talklib-2.2.0/src/talklib.egg-info → talklib-3.0.0}/PKG-INFO +1 -1
- {talklib-2.2.0 → talklib-3.0.0}/pyproject.toml +5 -1
- talklib-3.0.0/src/talklib/cli.py +88 -0
- {talklib-2.2.0 → talklib-3.0.0}/src/talklib/pod.py +14 -1
- {talklib-2.2.0 → talklib-3.0.0/src/talklib.egg-info}/PKG-INFO +1 -1
- {talklib-2.2.0 → talklib-3.0.0}/src/talklib.egg-info/SOURCES.txt +2 -0
- talklib-3.0.0/src/talklib.egg-info/entry_points.txt +2 -0
- {talklib-2.2.0 → talklib-3.0.0}/LICENSE.txt +0 -0
- {talklib-2.2.0 → talklib-3.0.0}/README.md +0 -0
- {talklib-2.2.0 → talklib-3.0.0}/requirements.txt +0 -0
- {talklib-2.2.0 → talklib-3.0.0}/setup.cfg +0 -0
- {talklib-2.2.0 → talklib-3.0.0}/src/talklib/__init__.py +0 -0
- {talklib-2.2.0 → talklib-3.0.0}/src/talklib/ev.py +0 -0
- {talklib-2.2.0 → talklib-3.0.0}/src/talklib/ffmpeg.py +0 -0
- {talklib-2.2.0 → talklib-3.0.0}/src/talklib/notify.py +0 -0
- {talklib-2.2.0 → talklib-3.0.0}/src/talklib/show.py +0 -0
- {talklib-2.2.0 → talklib-3.0.0}/src/talklib/utils.py +0 -0
- {talklib-2.2.0 → talklib-3.0.0}/src/talklib.egg-info/dependency_links.txt +0 -0
- {talklib-2.2.0 → talklib-3.0.0}/src/talklib.egg-info/requires.txt +0 -0
- {talklib-2.2.0 → talklib-3.0.0}/src/talklib.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "talklib"
|
|
3
|
-
version = "
|
|
3
|
+
version = "3.0.0"
|
|
4
4
|
description = "A package to automate processing of shows/segments airing on the TL"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = {file = "LICENSE.txt"}
|
|
@@ -23,3 +23,7 @@ build-backend = "setuptools.build_meta"
|
|
|
23
23
|
where = ["src"]
|
|
24
24
|
include = ["talklib*"]
|
|
25
25
|
exclude = [".tests*"]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
[project.scripts]
|
|
29
|
+
talklib = "talklib.cli:main"
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
import xml.etree.ElementTree as ET
|
|
5
|
+
|
|
6
|
+
from talklib.pod import SSH
|
|
7
|
+
|
|
8
|
+
def parse_args():
|
|
9
|
+
parser = argparse.ArgumentParser(description="use talklib in the terminal")
|
|
10
|
+
|
|
11
|
+
feed_template_help = "Generate an RSS feed template in the current directory"
|
|
12
|
+
parser.add_argument('--feed-template', action='store_true', help=feed_template_help, required=False)
|
|
13
|
+
|
|
14
|
+
new_podcast_directory_help = "Creates a new podcast directory on the server with the value you pass in. \
|
|
15
|
+
You MUST have an RSS feed (feed.xml) and logo (image.jpg) in the current directory."
|
|
16
|
+
parser.add_argument('--new-pod-dir', type=str, help=new_podcast_directory_help, required=False)
|
|
17
|
+
|
|
18
|
+
args = parser.parse_args()
|
|
19
|
+
|
|
20
|
+
return args
|
|
21
|
+
|
|
22
|
+
def generate_feed_template():
|
|
23
|
+
ET.register_namespace(prefix="atom", uri="http://www.w3.org/2005/Atom")
|
|
24
|
+
ET.register_namespace(prefix="itunes", uri="http://www.itunes.com/dtds/podcast-1.0.dtd")
|
|
25
|
+
feed = ET.fromstring(feed_template)
|
|
26
|
+
tree = ET.ElementTree(feed)
|
|
27
|
+
tree.write("feed.xml", encoding="utf-8", xml_declaration=True)
|
|
28
|
+
# feed.write("feed.xml", encoding="utf-8", xml_declaration=True)
|
|
29
|
+
print("'feed.xml' file created in " + os.getcwd())
|
|
30
|
+
return
|
|
31
|
+
|
|
32
|
+
def new_podcast_dir(name: str):
|
|
33
|
+
if not os.path.isfile("feed.xml"):
|
|
34
|
+
return print(f"cannot find 'feed.xml' in {os.getcwd()}. You must have this file in the current directory.")
|
|
35
|
+
|
|
36
|
+
if not os.path.isfile("image.jpg"):
|
|
37
|
+
return print(f"cannot find 'image.jpg' in {os.getcwd()}. You must have this file in the current directory.")
|
|
38
|
+
|
|
39
|
+
print("generating new podcast directory called " + name)
|
|
40
|
+
|
|
41
|
+
ssh = SSH()
|
|
42
|
+
ssh.make_new_folder(folder=name)
|
|
43
|
+
ssh.upload_file(file="feed.xml", folder=name)
|
|
44
|
+
ssh.upload_file(file="image.jpg", folder=name)
|
|
45
|
+
|
|
46
|
+
print("done! you can now delete the local copies of the files")
|
|
47
|
+
return
|
|
48
|
+
|
|
49
|
+
def main():
|
|
50
|
+
if len(sys.argv) == 1: # if no arguments are passed
|
|
51
|
+
return print("talklib -h for help")
|
|
52
|
+
args = parse_args()
|
|
53
|
+
|
|
54
|
+
if args.feed_template:
|
|
55
|
+
generate_feed_template()
|
|
56
|
+
if args.new_pod_dir:
|
|
57
|
+
new_podcast_dir(name=args.new_pod_dir)
|
|
58
|
+
|
|
59
|
+
feed_template: str = """
|
|
60
|
+
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
|
|
61
|
+
<channel>
|
|
62
|
+
<title>!!CHANGEME!!</title>
|
|
63
|
+
<link>http://nashvilletalkinglibrary.org/</link>
|
|
64
|
+
<atom:link href="https://assets.library.nashville.org/talkinglibrary/shows/!!CHANGEME!!/feed.xml" rel="self" type="application/rss+xml" />
|
|
65
|
+
<description>
|
|
66
|
+
!!CHANGEME!!
|
|
67
|
+
</description>
|
|
68
|
+
<copyright>© 1975-2022 Nashville Talking Library - Do not copy or redistribute</copyright>
|
|
69
|
+
<docs>https://cyber.harvard.edu/rss/rss.html</docs>
|
|
70
|
+
<generator>NTL Python Magic</generator>
|
|
71
|
+
<webMaster>nashvilletalkinglibrary@gmail.com (Darth Vader)</webMaster>
|
|
72
|
+
<itunes:owner>
|
|
73
|
+
<itunes:name>Nashville Talking Library</itunes:name>
|
|
74
|
+
<itunes:email>ntl@nashville.gov</itunes:email>
|
|
75
|
+
</itunes:owner>
|
|
76
|
+
<itunes:category text="Education" />
|
|
77
|
+
<itunes:explicit>true</itunes:explicit>
|
|
78
|
+
<itunes:image href="https://assets.library.nashville.org/talkinglibrary/shows/!!CHANGEME!!/image.jpg" />
|
|
79
|
+
<image>
|
|
80
|
+
<url>https://assets.library.nashville.org/talkinglibrary/shows/!!CHANGEME!!/image.jpg</url>
|
|
81
|
+
<title>!!CHANGEME!!</title>
|
|
82
|
+
<link>http://nashvilletalkinglibrary.org/</link>
|
|
83
|
+
</image>
|
|
84
|
+
<language>en</language>
|
|
85
|
+
<lastBuildDate>leave me alone</lastBuildDate>
|
|
86
|
+
</channel>
|
|
87
|
+
</rss>
|
|
88
|
+
"""
|
|
@@ -90,6 +90,12 @@ The error from the SSH library is: {e}"
|
|
|
90
90
|
self.notifications.send_notifications(
|
|
91
91
|
message=f"Unable to delete '{file}' from {folder}: {e}. Continuing automation...",
|
|
92
92
|
subject="Error")
|
|
93
|
+
|
|
94
|
+
def make_new_folder(self, folder: str) -> None:
|
|
95
|
+
if self.check_folder_exists_no_exception(folder=folder):
|
|
96
|
+
raise Exception (f"{folder}/ already exists on server! Exiting...")
|
|
97
|
+
self.connection.run(f"cd shows && mkdir {folder}", hide=True)
|
|
98
|
+
self.notifications.prep_syslog(message=f"{folder}/ created on server")
|
|
93
99
|
|
|
94
100
|
def get_folders(self) -> list:
|
|
95
101
|
ret_val: list = []
|
|
@@ -135,6 +141,13 @@ The error from the SSH library is: {e}"
|
|
|
135
141
|
self.notifications.send_notifications(message=to_send, subject='Error')
|
|
136
142
|
raise Exception (to_send)
|
|
137
143
|
|
|
144
|
+
def check_folder_exists_no_exception(self, folder: str):
|
|
145
|
+
self.notifications.prep_syslog(message=f"checking if {folder}/ exists on server...")
|
|
146
|
+
folders = self.get_folders()
|
|
147
|
+
if folder.lower() in folders:
|
|
148
|
+
self.notifications.prep_syslog(message=f"{folder}/ exists on server!")
|
|
149
|
+
return True
|
|
150
|
+
|
|
138
151
|
|
|
139
152
|
class Episode(BaseModel):
|
|
140
153
|
feed_file: str = Field(min_length=1, default=None)
|
|
@@ -161,7 +174,7 @@ class Episode(BaseModel):
|
|
|
161
174
|
return size_in_bytes
|
|
162
175
|
|
|
163
176
|
def enclosure(self) -> str:
|
|
164
|
-
enclosure = f"https://
|
|
177
|
+
enclosure = f"https://assets.library.nashville.org/talkinglibrary/shows/{self.bucket_folder}/{self.audio_filename}"
|
|
165
178
|
self.notifications.prep_syslog(message=f"enclosure will be {enclosure}")
|
|
166
179
|
return enclosure
|
|
167
180
|
|
|
@@ -3,6 +3,7 @@ README.md
|
|
|
3
3
|
pyproject.toml
|
|
4
4
|
requirements.txt
|
|
5
5
|
src/talklib/__init__.py
|
|
6
|
+
src/talklib/cli.py
|
|
6
7
|
src/talklib/ev.py
|
|
7
8
|
src/talklib/ffmpeg.py
|
|
8
9
|
src/talklib/notify.py
|
|
@@ -12,5 +13,6 @@ src/talklib/utils.py
|
|
|
12
13
|
src/talklib.egg-info/PKG-INFO
|
|
13
14
|
src/talklib.egg-info/SOURCES.txt
|
|
14
15
|
src/talklib.egg-info/dependency_links.txt
|
|
16
|
+
src/talklib.egg-info/entry_points.txt
|
|
15
17
|
src/talklib.egg-info/requires.txt
|
|
16
18
|
src/talklib.egg-info/top_level.txt
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|