talklib 3.2.1__tar.gz → 3.2.3__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.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: talklib
3
- Version: 3.2.1
3
+ Version: 3.2.3
4
4
  Summary: A package to automate processing of shows/segments airing on the TL
5
5
  Author-email: Ben Weddle <ben.weddle@gmail.com>
6
6
  Maintainer-email: Ben Weddle <ben.weddle@gmail.com>
@@ -97,6 +97,7 @@ Requires-Dist: urllib3==2.2.2
97
97
  Requires-Dist: wrapt==1.16.0
98
98
  Requires-Dist: yarl==1.9.2
99
99
  Requires-Dist: zipp==3.17.0
100
+ Dynamic: license-file
100
101
 
101
102
  # talklib
102
103
 
@@ -474,7 +475,9 @@ SD.run()
474
475
 
475
476
  ### Prerequisites
476
477
 
477
- Before starting to podcast a new show, you must log in to the server and create a directory. The directory should be named the same as the base name of the audio files for that show. For example, The Nashville Scene audio files are labelled as SceneMMDDYY. The directory name on the server should be `scene` in all lower-case.
478
+ Before starting to podcast a new show, you must log in to the server, create a directory, and upload some files. The `talklib` CLI has several functions to help you with this. Run `talklib --help` in your terminal to see a list of these helper functions.
479
+
480
+ The directory should be named the same as the base name of the audio files for that show. For example, The Nashville Scene audio files are labelled as SceneMMDDYY. The directory name on the server should be `scene` in all lower-case.
478
481
 
479
482
  You must also add two files to this directory: an RSS Feed and and an image.
480
483
 
@@ -523,7 +526,7 @@ nyt.run()
523
526
 
524
527
  To disable ALL notifications, add a line like this:
525
528
 
526
- > This will disable all notifications **including** syslog messages (shell print statements will not be disabled)
529
+ > This will disable all notifications **including** syslog messages (terminal print statements will not be disabled)
527
530
 
528
531
  ````python
529
532
  from talklib import TLPod
@@ -536,6 +539,21 @@ nyt.notifications.notify.enable_all = False
536
539
  nyt.run()
537
540
  ````
538
541
 
542
+ If the name of the corresponding directory on the server is different from the `filename_to_match` value, adjust for that like this:
543
+
544
+ ````python
545
+ from talklib import TLPod
546
+
547
+ nyt = TLPod(
548
+ display_name = "New York Times",
549
+ filename_to_match = "nyt",
550
+ bucket_folder = "newyorktimes"
551
+ )
552
+ nyt.run()
553
+ ````
554
+
555
+ > This will match audio files that start with `nyt`, and will upload the files to the server directory called `newyorktimes`.
556
+
539
557
  -----
540
558
  ## Development<a id="development"></a>
541
559
 
@@ -374,7 +374,9 @@ SD.run()
374
374
 
375
375
  ### Prerequisites
376
376
 
377
- Before starting to podcast a new show, you must log in to the server and create a directory. The directory should be named the same as the base name of the audio files for that show. For example, The Nashville Scene audio files are labelled as SceneMMDDYY. The directory name on the server should be `scene` in all lower-case.
377
+ Before starting to podcast a new show, you must log in to the server, create a directory, and upload some files. The `talklib` CLI has several functions to help you with this. Run `talklib --help` in your terminal to see a list of these helper functions.
378
+
379
+ The directory should be named the same as the base name of the audio files for that show. For example, The Nashville Scene audio files are labelled as SceneMMDDYY. The directory name on the server should be `scene` in all lower-case.
378
380
 
379
381
  You must also add two files to this directory: an RSS Feed and and an image.
380
382
 
@@ -423,7 +425,7 @@ nyt.run()
423
425
 
424
426
  To disable ALL notifications, add a line like this:
425
427
 
426
- > This will disable all notifications **including** syslog messages (shell print statements will not be disabled)
428
+ > This will disable all notifications **including** syslog messages (terminal print statements will not be disabled)
427
429
 
428
430
  ````python
429
431
  from talklib import TLPod
@@ -436,6 +438,21 @@ nyt.notifications.notify.enable_all = False
436
438
  nyt.run()
437
439
  ````
438
440
 
441
+ If the name of the corresponding directory on the server is different from the `filename_to_match` value, adjust for that like this:
442
+
443
+ ````python
444
+ from talklib import TLPod
445
+
446
+ nyt = TLPod(
447
+ display_name = "New York Times",
448
+ filename_to_match = "nyt",
449
+ bucket_folder = "newyorktimes"
450
+ )
451
+ nyt.run()
452
+ ````
453
+
454
+ > This will match audio files that start with `nyt`, and will upload the files to the server directory called `newyorktimes`.
455
+
439
456
  -----
440
457
  ## Development<a id="development"></a>
441
458
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "talklib"
3
- version = "3.2.1"
3
+ version = "3.2.3"
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"}
@@ -41,21 +41,27 @@ import os
41
41
  class EV:
42
42
  def __init__(self):
43
43
  self.destinations = sort_destinations() # where should output files go? MUST BE A LIST EVEN WITH ONLY ONE
44
- self.syslog_host = os.environ["syslog_server"] # ip of syslog server (PC with syslog software)
45
- self.fromEmail = os.environ['fromEmail'] # from where should emails appear to come?
46
- self.toEmail = sort_to_email() # to where should emails be sent?
47
- self.mail_server = os.environ["mail_server_external"] # IP of mail server (ITS set this up for us)
48
- self.twilio_sid = os.environ['twilio_sid'] # locate by logging in to Twilio website
49
- self.twilio_token = os.environ['twilio_token']# locate by logging in to Twilio website
50
- self.twilio_from = os.environ['twilio_from'] # locate by logging in to Twilio website
44
+ self.syslog_host = get_EV(ev="syslog_server") # ip of syslog server (PC with syslog software)
45
+ self.fromEmail = get_EV(ev="fromEmail") # from where should emails appear to come?
46
+ self.toEmail = sort_to_email() # to where should emails be sent?
47
+ self.mail_server = get_EV(ev="mail_server_external") # IP of mail server (ITS set this up for us)
48
+ self.twilio_sid = get_EV(ev="twilio_sid") # locate by logging in to Twilio website
49
+ self.twilio_token = get_EV(ev="twilio_token") # locate by logging in to Twilio website
50
+ self.twilio_from = get_EV(ev="twilio_from") # locate by logging in to Twilio website
51
51
  self.twilio_to = sort_twilio_to() # to where should texts/calls be sent
52
- self.icecast_user = os.environ['icecast_user'] # our icecast username
53
- self.icecast_pass = os.environ['icecast_pass'] # our icecast password
54
- self.pod_server_uname = os.environ['pod_server_uname']
52
+ self.icecast_user = get_EV(ev="icecast_user") # our icecast username
53
+ self.icecast_pass = get_EV(ev="icecast_pass") # our icecast password
54
+ self.pod_server_uname = get_EV(ev="pod_server_uname")
55
55
 
56
+ def get_EV(ev: str):
57
+ try:
58
+ ev = os.environ[ev]
59
+ return ev
60
+ except KeyError:
61
+ raise RuntimeError(f"Missing required environment variable: {ev}")
56
62
 
57
63
  def sort_destinations():
58
- destinations = os.environ['destinations']
64
+ destinations = get_EV(ev="destinations")
59
65
  destinations = destinations.split(",")
60
66
  destination_list = []
61
67
  for destination in destinations:
@@ -66,7 +72,7 @@ def sort_destinations():
66
72
  return destination_list
67
73
 
68
74
  def sort_to_email():
69
- to_emails = os.environ['toEmail']
75
+ to_emails = get_EV(ev="toEmail")
70
76
  to_emails = to_emails.split(",")
71
77
  to_email_list = []
72
78
  for email in to_emails:
@@ -76,7 +82,7 @@ def sort_to_email():
76
82
  return to_email_list
77
83
 
78
84
  def sort_twilio_to():
79
- twilio_to_numbers = os.environ['twilio_to']
85
+ twilio_to_numbers = get_EV(ev="twilio_to")
80
86
  twilio_to_numbers = twilio_to_numbers.split(",")
81
87
  twilio_to_list = []
82
88
  for number in twilio_to_numbers:
@@ -43,7 +43,7 @@ class Notifications(BaseModel):
43
43
  self.prep_send_mail(message=message, subject=subject)
44
44
  self.prep_syslog(message=message, level=syslog_level)
45
45
  else:
46
- self.send_sms_if_enabled(message=message)
46
+ self.send_sms_if_enabled(message=self.prefix + ": " + message)
47
47
  self.prep_send_mail(message=message, subject=subject)
48
48
  self.prep_syslog(message=message, level=syslog_level)
49
49
 
@@ -52,6 +52,7 @@ class SSH(BaseModel):
52
52
  user: str = EV().pod_server_uname
53
53
  connection: Type[Connection] = Connection(host=server, user=user)
54
54
  notifications: Notifications = Notifications()
55
+ folder_exists: ClassVar[str] = False
55
56
 
56
57
  def upload_file(self, file: str, folder: str) -> None:
57
58
  self.check_folder_exists(folder=folder)
@@ -139,10 +140,13 @@ The error from the SSH library is: {e}"
139
140
  self.upload_file(file="feed.xml", folder=folder)
140
141
 
141
142
  def check_folder_exists(self, folder: str) -> bool:
143
+ if SSH.folder_exists:
144
+ return True
142
145
  self.notifications.prep_syslog(message=f"checking if {folder}/ exists on server...")
143
146
  folders = self.get_folders()
144
147
  if folder.lower() in folders:
145
148
  self.notifications.prep_syslog(message=f"{folder}/ exists on server!")
149
+ SSH.folder_exists = True
146
150
  return True
147
151
 
148
152
  to_send = f"cannot find folder titled: {folder}/ on server"
@@ -175,6 +179,12 @@ class Episode(BaseModel):
175
179
  self.notifications.prep_syslog(message=f"pubDate will be: {pub_date}")
176
180
  return pub_date
177
181
 
182
+ def copyright(self) -> str:
183
+ year: int = datetime.now().year
184
+ copyright: str = f"© 1975-{year} Nashville Talking Library - Do not copy or redistribute"
185
+ self.notifications.prep_syslog(message=f"copyright will be: {copyright}")
186
+ return copyright
187
+
178
188
  def size_in_bytes(self, filename) -> str:
179
189
  size_in_bytes = os.path.getsize(filename)
180
190
  size_in_bytes = str(size_in_bytes)
@@ -298,6 +308,9 @@ class Episode(BaseModel):
298
308
  last_build_date = root.find('lastBuildDate')
299
309
  last_build_date.text = self.pub_date() # fine to use this same pub date, as the format for both is the same
300
310
 
311
+ copyright = root.find("copyright")
312
+ copyright.text = self.copyright()
313
+
301
314
  ET.indent(feed) # makes the XML pretty looking
302
315
  self.notifications.prep_syslog(message=f"writing feed file...")
303
316
  feed.write(self.feed_file, encoding="utf-8", xml_declaration=True)
@@ -192,7 +192,7 @@ It looks like the downloaded file is empty. Please check manually! Yesterday's f
192
192
  self.__prep_send_mail(message=message, subject=subject)
193
193
  self.__prep_syslog(message=message, level=syslog_level)
194
194
  else:
195
- self.__send_sms_if_enabled(message=message)
195
+ self.__send_sms_if_enabled(message=self.show + ": " + message)
196
196
  self.__prep_send_mail(message=message, subject=subject)
197
197
  self.__prep_syslog(message=message, level=syslog_level)
198
198
 
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: talklib
3
- Version: 3.2.1
3
+ Version: 3.2.3
4
4
  Summary: A package to automate processing of shows/segments airing on the TL
5
5
  Author-email: Ben Weddle <ben.weddle@gmail.com>
6
6
  Maintainer-email: Ben Weddle <ben.weddle@gmail.com>
@@ -97,6 +97,7 @@ Requires-Dist: urllib3==2.2.2
97
97
  Requires-Dist: wrapt==1.16.0
98
98
  Requires-Dist: yarl==1.9.2
99
99
  Requires-Dist: zipp==3.17.0
100
+ Dynamic: license-file
100
101
 
101
102
  # talklib
102
103
 
@@ -474,7 +475,9 @@ SD.run()
474
475
 
475
476
  ### Prerequisites
476
477
 
477
- Before starting to podcast a new show, you must log in to the server and create a directory. The directory should be named the same as the base name of the audio files for that show. For example, The Nashville Scene audio files are labelled as SceneMMDDYY. The directory name on the server should be `scene` in all lower-case.
478
+ Before starting to podcast a new show, you must log in to the server, create a directory, and upload some files. The `talklib` CLI has several functions to help you with this. Run `talklib --help` in your terminal to see a list of these helper functions.
479
+
480
+ The directory should be named the same as the base name of the audio files for that show. For example, The Nashville Scene audio files are labelled as SceneMMDDYY. The directory name on the server should be `scene` in all lower-case.
478
481
 
479
482
  You must also add two files to this directory: an RSS Feed and and an image.
480
483
 
@@ -523,7 +526,7 @@ nyt.run()
523
526
 
524
527
  To disable ALL notifications, add a line like this:
525
528
 
526
- > This will disable all notifications **including** syslog messages (shell print statements will not be disabled)
529
+ > This will disable all notifications **including** syslog messages (terminal print statements will not be disabled)
527
530
 
528
531
  ````python
529
532
  from talklib import TLPod
@@ -536,6 +539,21 @@ nyt.notifications.notify.enable_all = False
536
539
  nyt.run()
537
540
  ````
538
541
 
542
+ If the name of the corresponding directory on the server is different from the `filename_to_match` value, adjust for that like this:
543
+
544
+ ````python
545
+ from talklib import TLPod
546
+
547
+ nyt = TLPod(
548
+ display_name = "New York Times",
549
+ filename_to_match = "nyt",
550
+ bucket_folder = "newyorktimes"
551
+ )
552
+ nyt.run()
553
+ ````
554
+
555
+ > This will match audio files that start with `nyt`, and will upload the files to the server directory called `newyorktimes`.
556
+
539
557
  -----
540
558
  ## Development<a id="development"></a>
541
559
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes