talklib 2.1.2__tar.gz → 2.1.4__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.2
3
+ Version: 2.1.4
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>
@@ -102,7 +102,7 @@ Requires-Dist: zipp==3.17.0
102
102
 
103
103
  ![tests](https://github.com/Nashville-Public-Library/talklib/actions/workflows/talklib.yml/badge.svg)
104
104
  [![GitHub issues](https://img.shields.io/github/issues/Nashville-Public-Library/talklib.png)](https://github.com/Nashville-Public-Library/talklib/issues)
105
- [![last-commit](https://img.shields.io/github/last-commit/Nashville-Public-Library/talklib)](https://github.com/Nashville-Public-Library/talklib/commits/master)
105
+ [![last-commit](https://img.shields.io/github/last-commit/Nashville-Public-Library/talklib)](https://github.com/Nashville-Public-Library/talklib/commits/main)
106
106
 
107
107
  ## A package to automate processing TL shows/segments and podcasts
108
108
 
@@ -468,9 +468,17 @@ SD.run()
468
468
 
469
469
  ## TL Podcasts Usage
470
470
 
471
- `TLPod` is the main class to use.
471
+ ### Prerequisites
472
472
 
473
- Import the class to your script like this:
473
+ 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.
474
+
475
+ You must also add two files to this directory: an RSS Feed and and an image.
476
+
477
+ The RSS feed should be named `feed.xml`. The image (the logo for the show) should be named `image.jpg`. You should update the template RSS feed file for each program. There are several default values such as Title that need to be changed. They are marked as such in the template.
478
+
479
+ ### Scripts
480
+
481
+ `TLPod` is the main class to use. Import the class to your script like this:
474
482
 
475
483
  ````python
476
484
  from talklib import TLPod
@@ -490,23 +498,11 @@ from talklib import TLPod
490
498
  nyt = TLPod(
491
499
  display_name = "New York Times",
492
500
  filename_to_match = "nyt",
493
- categories = ["News and Politics"]
494
501
  )
495
502
  nyt.run()
496
503
  ````
497
504
 
498
- To add multiple category tags, do this:
499
505
 
500
- ````python
501
- from talklib import TLPod
502
-
503
- nyt = TLPod(
504
- display_name = "New York Times",
505
- filename_to_match = "nyt",
506
- categories = ["News and Politics", "National News", "International News"]
507
- )
508
- nyt.run()
509
- ````
510
506
 
511
507
  The default number of episodes allowed in a podcast feed at any given time is 5. To change that:
512
508
 
@@ -516,7 +512,6 @@ from talklib import TLPod
516
512
  nyt = TLPod(
517
513
  display_name = "New York Times",
518
514
  filename_to_match = "nyt",
519
- categories = ["News and Politics"],
520
515
  max_episodes_in_feed = 7
521
516
  )
522
517
  nyt.run()
@@ -2,7 +2,7 @@
2
2
 
3
3
  ![tests](https://github.com/Nashville-Public-Library/talklib/actions/workflows/talklib.yml/badge.svg)
4
4
  [![GitHub issues](https://img.shields.io/github/issues/Nashville-Public-Library/talklib.png)](https://github.com/Nashville-Public-Library/talklib/issues)
5
- [![last-commit](https://img.shields.io/github/last-commit/Nashville-Public-Library/talklib)](https://github.com/Nashville-Public-Library/talklib/commits/master)
5
+ [![last-commit](https://img.shields.io/github/last-commit/Nashville-Public-Library/talklib)](https://github.com/Nashville-Public-Library/talklib/commits/main)
6
6
 
7
7
  ## A package to automate processing TL shows/segments and podcasts
8
8
 
@@ -368,9 +368,17 @@ SD.run()
368
368
 
369
369
  ## TL Podcasts Usage
370
370
 
371
- `TLPod` is the main class to use.
371
+ ### Prerequisites
372
372
 
373
- Import the class to your script like this:
373
+ 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.
374
+
375
+ You must also add two files to this directory: an RSS Feed and and an image.
376
+
377
+ The RSS feed should be named `feed.xml`. The image (the logo for the show) should be named `image.jpg`. You should update the template RSS feed file for each program. There are several default values such as Title that need to be changed. They are marked as such in the template.
378
+
379
+ ### Scripts
380
+
381
+ `TLPod` is the main class to use. Import the class to your script like this:
374
382
 
375
383
  ````python
376
384
  from talklib import TLPod
@@ -390,23 +398,11 @@ from talklib import TLPod
390
398
  nyt = TLPod(
391
399
  display_name = "New York Times",
392
400
  filename_to_match = "nyt",
393
- categories = ["News and Politics"]
394
401
  )
395
402
  nyt.run()
396
403
  ````
397
404
 
398
- To add multiple category tags, do this:
399
405
 
400
- ````python
401
- from talklib import TLPod
402
-
403
- nyt = TLPod(
404
- display_name = "New York Times",
405
- filename_to_match = "nyt",
406
- categories = ["News and Politics", "National News", "International News"]
407
- )
408
- nyt.run()
409
- ````
410
406
 
411
407
  The default number of episodes allowed in a podcast feed at any given time is 5. To change that:
412
408
 
@@ -416,7 +412,6 @@ from talklib import TLPod
416
412
  nyt = TLPod(
417
413
  display_name = "New York Times",
418
414
  filename_to_match = "nyt",
419
- categories = ["News and Politics"],
420
415
  max_episodes_in_feed = 7
421
416
  )
422
417
  nyt.run()
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "talklib"
3
- version = "2.1.2"
3
+ version = "2.1.4"
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"}
@@ -170,24 +170,47 @@ class Episode(BaseModel):
170
170
  self.notifications.prep_syslog(message=f"itunes:duration will be {result}")
171
171
  return result
172
172
 
173
- def check_for_duplicate_episode(self, title: str):
173
+ def get_root_feed_file(self):
174
+ ET.register_namespace(prefix="atom", uri="http://www.w3.org/2005/Atom")
175
+ ET.register_namespace(prefix="itunes", uri="http://www.itunes.com/dtds/podcast-1.0.dtd")
176
+ feed = ET.parse(self.feed_file)
177
+ root = feed.getroot()
178
+ return root
179
+
180
+
181
+ def check_for_duplicate_episode(self):
174
182
  self.notifications.prep_syslog(message="checking for duplicate episode...")
175
- if title == self.episode_title:
176
- self.cleanup_files_on_abort()
177
- to_send = "Found episode with identical title already in feed. Aborting..."
178
- self.notifications.send_notifications(message=to_send, subject="Error")
179
- raise Exception (to_send)
183
+ root = self.get_root_feed_file()
184
+ channel = root.find("channel")
185
+ items = channel.findall("item")
186
+ for item in items:
187
+ item = item.find("title").text
188
+ if item == self.episode_title:
189
+ to_send = "Found episode with identical title already in feed. Aborting..."
190
+ self.notifications.send_notifications(message=to_send, subject="Error")
191
+ self.cleanup_files_on_abort()
192
+ raise Exception (to_send)
180
193
  self.notifications.prep_syslog(message="no duplicate episode found")
181
194
  return
182
195
 
183
196
  def cleanup_files_on_abort(self):
197
+ self.notifications.prep_syslog(message=f"Aborting automation, deleting local temp files...")
184
198
  files = glob.glob("*.mp3")
185
199
  for file in files:
186
- self.notifications.prep_syslog(message=f"Aborting automation, deleting local temp files: {file}")
187
- os.remove(file)
188
- self.notifications.prep_syslog(message=f"Aborting automation, deleting local temp files: feed.xml")
189
- os.remove("feed.xml")
190
-
200
+ self.notifications.prep_syslog(message=f"Attempting to delete: {file}")
201
+ try:
202
+ os.remove(file)
203
+ self.notifications.prep_syslog(message=f"Successfully deleted: {file}")
204
+ except:
205
+ self.notifications.prep_syslog(message=f"Unable to delete {file}")
206
+
207
+ self.notifications.prep_syslog(message=f"Attempting to delete: feed.xml")
208
+ try:
209
+ os.remove("feed.xml")
210
+ self.notifications.prep_syslog(message=f"Successfully deleted: feed.xml")
211
+ except:
212
+ self.notifications.prep_syslog(message=f"Unable to delete:: feed.xml")
213
+
191
214
  def add_new_episode(self):
192
215
  '''Create an 'item' element. Then create all of the necessary sub elements and append them to the item element'''
193
216
  ET.register_namespace(prefix="atom", uri="http://www.w3.org/2005/Atom")
@@ -197,10 +220,7 @@ class Episode(BaseModel):
197
220
  root = root.find('channel')
198
221
 
199
222
  # if we have a new feed, or a feed with no episodes
200
- try:
201
- self.check_for_duplicate_episode(title=root.find("item").find("title").text)
202
- except:
203
- pass
223
+ self.check_for_duplicate_episode()
204
224
 
205
225
  self.notifications.prep_syslog(message="Building the new <item> element")
206
226
  item = ET.Element('item')
@@ -323,9 +343,10 @@ class TLPod(BaseModel):
323
343
  def get_filename_to_match(self) -> str:
324
344
  if self.override_filename:
325
345
  self.notifications.prep_syslog(message="filename override is turned ON")
326
- return self.filename_to_match.lower()
346
+ file = (self.filename_to_match + ".wav").lower()
347
+ return file
327
348
  today_date: str = datetime.now().strftime("%m%d%y") # this is how we date our programs: MMDDYY
328
- return (self.filename_to_match + today_date).lower()
349
+ return (self.filename_to_match + today_date + ".wav").lower()
329
350
 
330
351
  def match_file(self):
331
352
  '''match the name of the program that has today's date in the filename'''
@@ -335,8 +356,9 @@ class TLPod(BaseModel):
335
356
  self.notifications.prep_syslog(message=f"searching for {to_match} in {dest}...")
336
357
  files = glob.glob(f"{dest}/*.wav")
337
358
  for file in files:
338
- if to_match in file.lower():
339
- self.notifications.prep_syslog(message="found matching file!")
359
+ basename = os.path.basename(file)
360
+ if to_match == basename.lower():
361
+ self.notifications.prep_syslog(message=f"found matching file: {file}")
340
362
  return file
341
363
  to_send = f"There was a problem podcasting {self.display_name}. Cannot find matched file {to_match} in {self.audio_folders}"
342
364
  self.notifications.send_notifications(message=to_send, subject='Error')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: talklib
3
- Version: 2.1.2
3
+ Version: 2.1.4
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>
@@ -102,7 +102,7 @@ Requires-Dist: zipp==3.17.0
102
102
 
103
103
  ![tests](https://github.com/Nashville-Public-Library/talklib/actions/workflows/talklib.yml/badge.svg)
104
104
  [![GitHub issues](https://img.shields.io/github/issues/Nashville-Public-Library/talklib.png)](https://github.com/Nashville-Public-Library/talklib/issues)
105
- [![last-commit](https://img.shields.io/github/last-commit/Nashville-Public-Library/talklib)](https://github.com/Nashville-Public-Library/talklib/commits/master)
105
+ [![last-commit](https://img.shields.io/github/last-commit/Nashville-Public-Library/talklib)](https://github.com/Nashville-Public-Library/talklib/commits/main)
106
106
 
107
107
  ## A package to automate processing TL shows/segments and podcasts
108
108
 
@@ -468,9 +468,17 @@ SD.run()
468
468
 
469
469
  ## TL Podcasts Usage
470
470
 
471
- `TLPod` is the main class to use.
471
+ ### Prerequisites
472
472
 
473
- Import the class to your script like this:
473
+ 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.
474
+
475
+ You must also add two files to this directory: an RSS Feed and and an image.
476
+
477
+ The RSS feed should be named `feed.xml`. The image (the logo for the show) should be named `image.jpg`. You should update the template RSS feed file for each program. There are several default values such as Title that need to be changed. They are marked as such in the template.
478
+
479
+ ### Scripts
480
+
481
+ `TLPod` is the main class to use. Import the class to your script like this:
474
482
 
475
483
  ````python
476
484
  from talklib import TLPod
@@ -490,23 +498,11 @@ from talklib import TLPod
490
498
  nyt = TLPod(
491
499
  display_name = "New York Times",
492
500
  filename_to_match = "nyt",
493
- categories = ["News and Politics"]
494
501
  )
495
502
  nyt.run()
496
503
  ````
497
504
 
498
- To add multiple category tags, do this:
499
505
 
500
- ````python
501
- from talklib import TLPod
502
-
503
- nyt = TLPod(
504
- display_name = "New York Times",
505
- filename_to_match = "nyt",
506
- categories = ["News and Politics", "National News", "International News"]
507
- )
508
- nyt.run()
509
- ````
510
506
 
511
507
  The default number of episodes allowed in a podcast feed at any given time is 5. To change that:
512
508
 
@@ -516,7 +512,6 @@ from talklib import TLPod
516
512
  nyt = TLPod(
517
513
  display_name = "New York Times",
518
514
  filename_to_match = "nyt",
519
- categories = ["News and Politics"],
520
515
  max_episodes_in_feed = 7
521
516
  )
522
517
  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