talklib 2.0.7__tar.gz → 2.1.1__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.1
2
2
  Name: talklib
3
- Version: 2.0.7
3
+ Version: 2.1.1
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.0.7"
3
+ version = "2.1.1"
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"}
@@ -134,7 +134,6 @@ class Episode(BaseModel):
134
134
  episode_title: str = Field(min_length=1, default=None)
135
135
  notifications: Notifications = Notifications()
136
136
  max_episodes: int = Field(default=None)
137
- categories: list = Field(default=None)
138
137
 
139
138
  def pub_date(self) -> str:
140
139
  timezone = time.timezone/60/60 # 60 seconds per minute, 60 minutes per hour
@@ -170,7 +169,23 @@ class Episode(BaseModel):
170
169
  result = f"{minutes}:{seconds:02}"
171
170
  self.notifications.prep_syslog(message=f"itunes:duration will be {result}")
172
171
  return result
173
-
172
+
173
+ def check_for_duplicate_episode(self, title: str):
174
+ if title == self.episode_title:
175
+ self.cleanup_files_on_abort()
176
+ to_send = "Found episode with identical title already in feed. Aborting..."
177
+ self.notifications.send_notifications(message=to_send, subject="Error")
178
+ raise Exception (to_send)
179
+ return
180
+
181
+ def cleanup_files_on_abort(self):
182
+ files = glob.glob("*.mp3")
183
+ for file in files:
184
+ self.notifications.prep_syslog(message=f"Aborting automation, deleting local temp files: {file}")
185
+ os.remove(file)
186
+ self.notifications.prep_syslog(message=f"Aborting automation, deleting local temp files: feed.xml")
187
+ os.remove("feed.xml")
188
+
174
189
  def add_new_episode(self):
175
190
  '''Create an 'item' element. Then create all of the necessary sub elements and append them to the item element'''
176
191
  ET.register_namespace(prefix="atom", uri="http://www.w3.org/2005/Atom")
@@ -179,6 +194,8 @@ class Episode(BaseModel):
179
194
  root = feed.getroot()
180
195
  root = root.find('channel')
181
196
 
197
+ self.check_for_duplicate_episode(title=root.find("item").find("title").text)
198
+
182
199
  self.notifications.prep_syslog(message="Building the new <item> element")
183
200
  item = ET.Element('item')
184
201
 
@@ -210,12 +227,6 @@ class Episode(BaseModel):
210
227
  itunes_duration_element.text = self.itunes_duration()
211
228
  item.append(itunes_duration_element)
212
229
 
213
- for category in self.categories:
214
- category_element = ET.Element("category")
215
- category_element.text = category
216
- self.notifications.prep_syslog(message=f"adding category: {category}")
217
- item.append(category_element)
218
-
219
230
  # insert the new 'item' element as the first item, but below all the other channel elements
220
231
  items = root.findall('item')
221
232
  if items:
@@ -277,7 +288,6 @@ class TLPod(BaseModel):
277
288
  '''
278
289
  display_name: str = Field(min_length=1)
279
290
  filename_to_match: str = Field(min_length=1)
280
- categories: list = Field(default=[])
281
291
  bucket_folder: str = Field(default=None)
282
292
  max_episodes_in_feed: int = Field(ge=1, default=5)
283
293
  override_filename: bool = False
@@ -376,7 +386,6 @@ class TLPod(BaseModel):
376
386
  self.episode.feed_file = feed_file
377
387
  self.episode.audio_filename = converted_file
378
388
  self.episode.bucket_folder = self.bucket_folder
379
- self.episode.categories = self.categories
380
389
  self.episode.episode_title = f"{self.display_name} ({datetime.now().strftime('%a, %d %B')})"
381
390
  self.episode.max_episodes = self.max_episodes_in_feed
382
391
 
@@ -277,23 +277,29 @@ Is this a permalink show? Did you forget to set the is_permalink attribute?\n\n\
277
277
  a standards organization. Most podcasts/RSS feeds follow this standard.
278
278
  '''
279
279
  root = self.__get_feed()
280
- for channel in root.findall('channel'):
281
- item = channel.find('item') # 'find' only returns the first match!
282
- pub_date = item.find('pubDate').text
283
- today = datetime.now().strftime("%a, %d %b %Y")
284
- if today in pub_date:
285
- self.__prep_syslog(message='The feed is updated.')
286
- return True
280
+ channel = root.find('channel')
281
+ item = channel.find('item') # 'find' only returns the first match!
282
+ pub_date = item.find('pubDate').text
283
+ today = datetime.now().strftime("%a, %d %b %Y")
284
+ if today in pub_date:
285
+ self.__prep_syslog(message='The feed is updated.')
286
+ return True
287
287
 
288
288
  def __get_RSS_audio_url(self) -> str:
289
289
  '''TODO: explain'''
290
290
  root = self.__get_feed()
291
- for channel in root.findall('channel'):
292
- item = channel.find('item') # 'find' only returns the first match!
291
+ channel = root.find('channel')
292
+ item = channel.find('item') # 'find' only returns the first match!
293
+ try:
293
294
  audio_url = item.find('enclosure').attrib
294
295
  audio_url = audio_url.get('url')
295
296
  self.__prep_syslog(message=f'Audio URL is: {audio_url}')
296
297
  return audio_url
298
+ except AttributeError as AE:
299
+ to_send = f"There's a Problem with {self.show}. \
300
+ There is no 'enclosure' tag for the item. Here's the error: {AE}\n\n\{get_timestamp()}"
301
+ self.__send_notifications(message=to_send, subject="error")
302
+ raise_exception_and_wait(message=to_send, error=AE)
297
303
 
298
304
  def __check_feed_loop(self) -> str:
299
305
  '''
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: talklib
3
- Version: 2.0.7
3
+ Version: 2.1.1
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