talklib 2.1.5__tar.gz → 2.2.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: talklib
3
- Version: 2.1.5
3
+ Version: 2.2.0
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>
@@ -106,6 +106,8 @@ Requires-Dist: zipp==3.17.0
106
106
 
107
107
  ## A package to automate processing TL shows/segments and podcasts
108
108
 
109
+ [talklib on PyPI](https://pypi.org/project/talklib/)
110
+
109
111
  [Skip to Examples](#examples)
110
112
 
111
113
  *THIS README IS INTENDED TO ASSIST TL STAFF IN INSTALLING AND USING THIS PACKAGE*
@@ -130,7 +132,7 @@ Use Python 3.10 or higher.
130
132
  Make sure to select "add to PATH" during installation.
131
133
 
132
134
  ### -[FFmpeg](https://www.ffmpeg.org/download.html#build-windows)
133
- You need Windows binaries for both FFmpeg & FFprobe installed on the PC and added to the PATH:
135
+ You need both FFmpeg & FFprobe installed on the PC and added to the PATH:
134
136
 
135
137
  To repeat, **this package will not work without FFmpeg and FFprobe**.
136
138
 
@@ -139,6 +141,8 @@ FFmpeg and FFprobe should be two separate binaries.
139
141
  ### -[Twilio](https://www.twilio.com/)
140
142
  Twilio is used for SMS and phone call notifications.
141
143
 
144
+ THIS IS NOT SOMETHING YOU NEED TO DOWNLOAD/INSTALL.
145
+
142
146
  Access our TL Twilio info (token, etc.) by [logging in](https://www.twilio.com/login) to Twilio.
143
147
 
144
148
  See [below](#disable-twilio) for how to disable Twilio.
@@ -171,7 +175,7 @@ Before we begin, a general note:
171
175
  - The "Run" command in WR defaults to running from a different directory AND a different drive letter. This causes confusion.
172
176
  - WR also does not run `.py` files by default.
173
177
  - These are some of the reasons why we do not run `.py` files directly from WR.
174
- - Instead, we tell WR to run a Batch script (`.bat` file) which in turn will run the Python script (`.py` file).
178
+ - Instead, we tell WR to run a Batch script (`.bat` file) which in turn will automatically run the Python script (`.py` file).
175
179
  - Ensure the Batch & Python scripts are in the same directory.
176
180
  - A sample `.bat` file (`Example.bat`) is included in the [misc](https://github.com/Nashville-Public-Library/misc/tree/main/talklib_examples) repo.
177
181
  - Download this file and place it in the same folder as your Python file.
@@ -186,7 +190,7 @@ D:\wireready
186
190
  -WP.bat
187
191
  -WP.py
188
192
  ````
189
- You would schedule WR to run the `WP.bat` file, which would run the `WP.py` file.
193
+ You would schedule WR to run the `WP.bat` file, which would automatically run the `WP.py` file.
190
194
 
191
195
  ----
192
196
 
@@ -527,7 +531,6 @@ from talklib import TLPod
527
531
  nyt = TLPod(
528
532
  display_name = "New York Times",
529
533
  filename_to_match = "nyt",
530
- categories = ["News and Politics"],
531
534
  )
532
535
  nyt.notifications.notify.enable_all = False
533
536
  nyt.run()
@@ -6,6 +6,8 @@
6
6
 
7
7
  ## A package to automate processing TL shows/segments and podcasts
8
8
 
9
+ [talklib on PyPI](https://pypi.org/project/talklib/)
10
+
9
11
  [Skip to Examples](#examples)
10
12
 
11
13
  *THIS README IS INTENDED TO ASSIST TL STAFF IN INSTALLING AND USING THIS PACKAGE*
@@ -30,7 +32,7 @@ Use Python 3.10 or higher.
30
32
  Make sure to select "add to PATH" during installation.
31
33
 
32
34
  ### -[FFmpeg](https://www.ffmpeg.org/download.html#build-windows)
33
- You need Windows binaries for both FFmpeg & FFprobe installed on the PC and added to the PATH:
35
+ You need both FFmpeg & FFprobe installed on the PC and added to the PATH:
34
36
 
35
37
  To repeat, **this package will not work without FFmpeg and FFprobe**.
36
38
 
@@ -39,6 +41,8 @@ FFmpeg and FFprobe should be two separate binaries.
39
41
  ### -[Twilio](https://www.twilio.com/)
40
42
  Twilio is used for SMS and phone call notifications.
41
43
 
44
+ THIS IS NOT SOMETHING YOU NEED TO DOWNLOAD/INSTALL.
45
+
42
46
  Access our TL Twilio info (token, etc.) by [logging in](https://www.twilio.com/login) to Twilio.
43
47
 
44
48
  See [below](#disable-twilio) for how to disable Twilio.
@@ -71,7 +75,7 @@ Before we begin, a general note:
71
75
  - The "Run" command in WR defaults to running from a different directory AND a different drive letter. This causes confusion.
72
76
  - WR also does not run `.py` files by default.
73
77
  - These are some of the reasons why we do not run `.py` files directly from WR.
74
- - Instead, we tell WR to run a Batch script (`.bat` file) which in turn will run the Python script (`.py` file).
78
+ - Instead, we tell WR to run a Batch script (`.bat` file) which in turn will automatically run the Python script (`.py` file).
75
79
  - Ensure the Batch & Python scripts are in the same directory.
76
80
  - A sample `.bat` file (`Example.bat`) is included in the [misc](https://github.com/Nashville-Public-Library/misc/tree/main/talklib_examples) repo.
77
81
  - Download this file and place it in the same folder as your Python file.
@@ -86,7 +90,7 @@ D:\wireready
86
90
  -WP.bat
87
91
  -WP.py
88
92
  ````
89
- You would schedule WR to run the `WP.bat` file, which would run the `WP.py` file.
93
+ You would schedule WR to run the `WP.bat` file, which would automatically run the `WP.py` file.
90
94
 
91
95
  ----
92
96
 
@@ -427,7 +431,6 @@ from talklib import TLPod
427
431
  nyt = TLPod(
428
432
  display_name = "New York Times",
429
433
  filename_to_match = "nyt",
430
- categories = ["News and Politics"],
431
434
  )
432
435
  nyt.notifications.notify.enable_all = False
433
436
  nyt.run()
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "talklib"
3
- version = "2.1.5"
3
+ version = "2.2.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"}
@@ -8,6 +8,7 @@ import time
8
8
  from typing import ClassVar, Type
9
9
 
10
10
  from fabric import Connection, Result
11
+ from paramiko.ssh_exception import SSHException as paramiko_SSH_exception
11
12
  from pydantic import BaseModel, Field, model_validator
12
13
 
13
14
  from talklib.ev import EV
@@ -69,8 +70,13 @@ class SSH(BaseModel):
69
70
  self.connection.get(remote=f"shows/{folder}/{file}")
70
71
  self.notifications.prep_syslog(message=f"Successfully downloaded '{file}' to {os.getcwd()}")
71
72
  return file
72
- except Exception as e:
73
- to_send = f"unable to download '{file}': {e}"
73
+ except paramiko_SSH_exception as e:
74
+ to_send = f"unable to download '{file}' due to an authentication error. Are your SSH keys correctly configured?\n\
75
+ The error from the SSH library is: {e}"
76
+ self.notifications.send_notifications(message=to_send, subject='Error')
77
+ raise e
78
+ except FileNotFoundError as e:
79
+ to_send = f"Unable to download {file} from /{folder}. It seems the file does not exist: {e}"
74
80
  self.notifications.send_notifications(message=to_send, subject='Error')
75
81
  raise e
76
82
 
@@ -115,6 +121,9 @@ class SSH(BaseModel):
115
121
  ret_val.append(file.lower())
116
122
  return ret_val
117
123
 
124
+ def get_feed_from_folder(self, folder: str):
125
+ self.download_file(file="feed.xml", folder=folder)
126
+
118
127
  def check_folder_exists(self, folder: str) -> bool:
119
128
  self.notifications.prep_syslog(message=f"checking if {folder}/ exists on server...")
120
129
  folders = self.get_folders()
@@ -338,15 +347,35 @@ class TLPod(BaseModel):
338
347
  prefix = f"{self.display_name} (podcast)"
339
348
  Notifications.prefix = prefix
340
349
 
350
+ self.display_name = f"{self.display_name} ({datetime.now().strftime('%a, %d %b')})"
351
+
341
352
  return self
342
353
 
343
354
  def get_filename_to_match(self) -> str:
344
355
  if self.override_filename:
345
356
  self.notifications.prep_syslog(message="filename override is turned ON")
346
- file = (self.filename_to_match + ".wav").lower()
357
+ file = (self.filename_to_match).lower()
347
358
  return file
348
359
  today_date: str = datetime.now().strftime("%m%d%y") # this is how we date our programs: MMDDYY
349
- return (self.filename_to_match + today_date + ".wav").lower()
360
+ return (self.filename_to_match + today_date).lower()
361
+
362
+ def check_alt_endings(self,file: str):
363
+ file_lower_case: str = file.lower()
364
+
365
+ if file_lower_case.endswith("-sub.wav"):
366
+ self.notifications.prep_syslog(message=f"'-sub' found in filename: {file}. Amending 'display_name' for episode...")
367
+ self.display_name = f"{self.display_name} (Substitute)"
368
+ self.notifications.prep_syslog(message=f"New display_name: {self.display_name}")
369
+
370
+ if file_lower_case.endswith("-rep.wav"):
371
+ self.notifications.prep_syslog(message=f"'-rep' found in filename: {file}. Amending 'display_name' for episode...")
372
+ self.display_name = f"{self.display_name} (Encore)"
373
+ self.notifications.prep_syslog(message=f"New display_name: {self.display_name}")
374
+
375
+ if file_lower_case.endswith("-dnp.wav"):
376
+ to_send = f"'-dnp' found in filename ({file}), will NOT podcast this episode. Exiting automation!"
377
+ self.notifications.send_notifications(message=to_send, subject="Info", syslog_level="info")
378
+ raise Exception (to_send)
350
379
 
351
380
  def match_file(self):
352
381
  '''match the name of the program that has today's date in the filename'''
@@ -356,10 +385,17 @@ class TLPod(BaseModel):
356
385
  self.notifications.prep_syslog(message=f"searching for {to_match} in {dest}...")
357
386
  files = glob.glob(f"{dest}/*.wav")
358
387
  for file in files:
359
- basename = os.path.basename(file)
360
- if to_match == basename.lower():
388
+ if to_match in file.lower():
361
389
  self.notifications.prep_syslog(message=f"found matching file: {file}")
390
+
391
+ if "Copy (" in file:
392
+ self.notifications.prep_syslog(message=f"skipping file with 'copy' in filename: {file}")
393
+ continue
394
+
395
+ self.check_alt_endings(file=file)
396
+
362
397
  return file
398
+
363
399
  to_send = f"There was a problem podcasting {self.display_name}. Cannot find matched file {to_match} in {self.audio_folders}"
364
400
  self.notifications.send_notifications(message=to_send, subject='Error')
365
401
  raise FileNotFoundError
@@ -414,7 +450,7 @@ class TLPod(BaseModel):
414
450
  self.episode.feed_file = feed_file
415
451
  self.episode.audio_filename = converted_file
416
452
  self.episode.bucket_folder = self.bucket_folder
417
- self.episode.episode_title = f"{self.display_name} ({datetime.now().strftime('%a, %d %B')})"
453
+ self.episode.episode_title = self.display_name
418
454
  self.episode.max_episodes = self.max_episodes_in_feed
419
455
 
420
456
  self.episode.add_new_episode()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: talklib
3
- Version: 2.1.5
3
+ Version: 2.2.0
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>
@@ -106,6 +106,8 @@ Requires-Dist: zipp==3.17.0
106
106
 
107
107
  ## A package to automate processing TL shows/segments and podcasts
108
108
 
109
+ [talklib on PyPI](https://pypi.org/project/talklib/)
110
+
109
111
  [Skip to Examples](#examples)
110
112
 
111
113
  *THIS README IS INTENDED TO ASSIST TL STAFF IN INSTALLING AND USING THIS PACKAGE*
@@ -130,7 +132,7 @@ Use Python 3.10 or higher.
130
132
  Make sure to select "add to PATH" during installation.
131
133
 
132
134
  ### -[FFmpeg](https://www.ffmpeg.org/download.html#build-windows)
133
- You need Windows binaries for both FFmpeg & FFprobe installed on the PC and added to the PATH:
135
+ You need both FFmpeg & FFprobe installed on the PC and added to the PATH:
134
136
 
135
137
  To repeat, **this package will not work without FFmpeg and FFprobe**.
136
138
 
@@ -139,6 +141,8 @@ FFmpeg and FFprobe should be two separate binaries.
139
141
  ### -[Twilio](https://www.twilio.com/)
140
142
  Twilio is used for SMS and phone call notifications.
141
143
 
144
+ THIS IS NOT SOMETHING YOU NEED TO DOWNLOAD/INSTALL.
145
+
142
146
  Access our TL Twilio info (token, etc.) by [logging in](https://www.twilio.com/login) to Twilio.
143
147
 
144
148
  See [below](#disable-twilio) for how to disable Twilio.
@@ -171,7 +175,7 @@ Before we begin, a general note:
171
175
  - The "Run" command in WR defaults to running from a different directory AND a different drive letter. This causes confusion.
172
176
  - WR also does not run `.py` files by default.
173
177
  - These are some of the reasons why we do not run `.py` files directly from WR.
174
- - Instead, we tell WR to run a Batch script (`.bat` file) which in turn will run the Python script (`.py` file).
178
+ - Instead, we tell WR to run a Batch script (`.bat` file) which in turn will automatically run the Python script (`.py` file).
175
179
  - Ensure the Batch & Python scripts are in the same directory.
176
180
  - A sample `.bat` file (`Example.bat`) is included in the [misc](https://github.com/Nashville-Public-Library/misc/tree/main/talklib_examples) repo.
177
181
  - Download this file and place it in the same folder as your Python file.
@@ -186,7 +190,7 @@ D:\wireready
186
190
  -WP.bat
187
191
  -WP.py
188
192
  ````
189
- You would schedule WR to run the `WP.bat` file, which would run the `WP.py` file.
193
+ You would schedule WR to run the `WP.bat` file, which would automatically run the `WP.py` file.
190
194
 
191
195
  ----
192
196
 
@@ -527,7 +531,6 @@ from talklib import TLPod
527
531
  nyt = TLPod(
528
532
  display_name = "New York Times",
529
533
  filename_to_match = "nyt",
530
- categories = ["News and Politics"],
531
534
  )
532
535
  nyt.notifications.notify.enable_all = False
533
536
  nyt.run()
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