@@ -357,8 +357,8 @@ def hasPreviewThumbnails(self):
357357 return any (part .hasPreviewThumbnails for media in self .media for part in media .parts )
358358
359359 def _prettyfilename (self ):
360- # This is just for compat.
361- return self .title
360+ """ Returns a filename for use in download. """
361+ return '%s (%s)' % ( self .title , self . year )
362362
363363 def reviews (self ):
364364 """ Returns a list of :class:`~plexapi.media.Review` objects. """
@@ -375,32 +375,6 @@ def hubs(self):
375375 data = self ._server .query (self ._details_key )
376376 return self .findItems (data , library .Hub , rtag = 'Related' )
377377
378- def download (self , savepath = None , keep_original_name = False , ** kwargs ):
379- """ Download video files to specified directory.
380-
381- Parameters:
382- savepath (str): Defaults to current working dir.
383- keep_original_name (bool): True to keep the original file name otherwise
384- a friendlier is generated.
385- **kwargs: Additional options passed into :func:`~plexapi.base.PlexObject.getStreamURL`.
386- """
387- filepaths = []
388- locations = [i for i in self .iterParts () if i ]
389- for location in locations :
390- name = location .file
391- if not keep_original_name :
392- title = self .title .replace (' ' , '.' )
393- name = '%s.%s' % (title , location .container )
394- if kwargs is not None :
395- url = self .getStreamURL (** kwargs )
396- else :
397- self ._server .url ('%s?download=1' % location .key )
398- filepath = utils .download (url , self ._server ._token , filename = name ,
399- savepath = savepath , session = self ._server ._session )
400- if filepath :
401- filepaths .append (filepath )
402- return filepaths
403-
404378
405379@utils .registerPlexObject
406380class Show (Video , AdvancedSettingsMixin , ArtMixin , BannerMixin , PosterMixin , RatingMixin , SplitMergeMixin , UnmatchMatchMixin ,
@@ -582,18 +556,20 @@ def unwatched(self):
582556 """ Returns list of unwatched :class:`~plexapi.video.Episode` objects. """
583557 return self .episodes (viewCount = 0 )
584558
585- def download (self , savepath = None , keep_original_name = False , ** kwargs ):
586- """ Download video files to specified directory .
559+ def download (self , savepath = None , keep_original_name = False , subfolders = False , ** kwargs ):
560+ """ Download all episodes from the show. See :func:`~plexapi.base.Playable.download` for details .
587561
588562 Parameters:
589563 savepath (str): Defaults to current working dir.
590- keep_original_name (bool): True to keep the original file name otherwise
591- a friendlier is generated.
564+ keep_original_name (bool): True to keep the original filename otherwise
565+ a friendlier filename is generated.
566+ subfolders (bool): True to separate episodes in to season folders.
592567 **kwargs: Additional options passed into :func:`~plexapi.base.PlexObject.getStreamURL`.
593568 """
594569 filepaths = []
595570 for episode in self .episodes ():
596- filepaths += episode .download (savepath , keep_original_name , ** kwargs )
571+ _savepath = os .path .join (savepath , 'Season %s' % str (episode .seasonNumber ).zfill (2 )) if subfolders else savepath
572+ filepaths += episode .download (_savepath , keep_original_name , ** kwargs )
597573 return filepaths
598574
599575
@@ -714,12 +690,12 @@ def unwatched(self):
714690 return self .episodes (viewCount = 0 )
715691
716692 def download (self , savepath = None , keep_original_name = False , ** kwargs ):
717- """ Download video files to specified directory .
693+ """ Download all episodes from the season. See :func:`~plexapi.base.Playable.download` for details .
718694
719695 Parameters:
720696 savepath (str): Defaults to current working dir.
721- keep_original_name (bool): True to keep the original file name otherwise
722- a friendlier is generated.
697+ keep_original_name (bool): True to keep the original filename otherwise
698+ a friendlier filename is generated.
723699 **kwargs: Additional options passed into :func:`~plexapi.base.PlexObject.getStreamURL`.
724700 """
725701 filepaths = []
@@ -839,8 +815,8 @@ def __repr__(self):
839815 ] if p ])
840816
841817 def _prettyfilename (self ):
842- """ Returns a human friendly filename . """
843- return '%s.%s ' % (self .grandparentTitle . replace ( ' ' , '.' ) , self .seasonEpisode )
818+ """ Returns a filename for use in download . """
819+ return '%s - %s - %s ' % (self .grandparentTitle , self . seasonEpisode , self .title )
844820
845821 @property
846822 def actors (self ):
@@ -953,6 +929,7 @@ def locations(self):
953929 return [part .file for part in self .iterParts () if part ]
954930
955931 def _prettyfilename (self ):
932+ """ Returns a filename for use in download. """
956933 return self .title
957934
958935
@@ -968,4 +945,5 @@ def _loadData(self, data):
968945 self .librarySectionTitle = parent .librarySectionTitle
969946
970947 def _prettyfilename (self ):
948+ """ Returns a filename for use in download. """
971949 return '%s (%s)' % (self .title , self .subtype )
0 commit comments