@@ -348,6 +348,15 @@ def channel(self):
348348 def db (self ):
349349 return self .parent .parent .db
350350
351+ @property
352+ def trimmed_title (self ):
353+ """Return the title with the common prefix trimmed"""
354+ if (self .parent ._common_prefix is not None and
355+ self .title .startswith (self .parent ._common_prefix )):
356+ return self .title [len (self .parent ._common_prefix ):]
357+
358+ return self .title
359+
351360 def _set_download_task (self , download_task ):
352361 self .children = (download_task , self .children [1 ])
353362
@@ -715,7 +724,7 @@ def update_from(self, episode):
715724
716725
717726class PodcastChannel (PodcastModelObject ):
718- __slots__ = schema .PodcastColumns
727+ __slots__ = schema .PodcastColumns + ( '_common_prefix' ,)
719728
720729 UNICODE_TRANSLATE = {ord (u'ö' ): u'o' , ord (u'ä' ): u'a' , ord (u'ü' ): u'u' }
721730
@@ -747,6 +756,7 @@ def __init__(self, model):
747756 self .pause_subscription = False
748757
749758 self .section = _ ('Other' )
759+ self ._common_prefix = None
750760
751761 @property
752762 def model (self ):
@@ -1213,6 +1223,14 @@ def get_downloaded_episodes(self):
12131223 def get_all_episodes (self ):
12141224 if self .children is None :
12151225 self .children = self .db .load_episodes (self , self .episode_factory )
1226+
1227+ prefix = os .path .commonprefix ([x .title for x in self .children ])
1228+ # The common prefix must end with a space - otherwise it's not
1229+ # on a word boundary, and we might end up chopping off too much
1230+ if prefix and prefix [- 1 ] != ' ' and ' ' in prefix :
1231+ prefix = prefix [:prefix .rfind (' ' )+ 1 ]
1232+ self ._common_prefix = prefix
1233+
12161234 return self .children
12171235
12181236 def find_unique_folder_name (self , download_folder ):
0 commit comments