talklib 2.1.2__tar.gz → 2.1.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
1
  Metadata-Version: 2.2
2
2
  Name: talklib
3
- Version: 2.1.2
3
+ Version: 2.1.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>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "talklib"
3
- version = "2.1.2"
3
+ version = "2.1.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"}
@@ -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.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>
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