@@ -34,7 +34,14 @@ def search_for_item(url=None):
3434 for i in items :
3535 if isinstance (i , Show ):
3636 display = lambda i : '%s %s %s' % (i .grandparentTitle , i .seasonEpisode , i .title )
37- item = utils .choose ('Choose episode' , i .episodes (), display )
37+ selected_eps = utils .choose ('Choose episode' , i .episodes (), display )
38+ if isinstance (selected_eps , list ):
39+ item += selected_eps
40+ else :
41+ item .append (selected_eps )
42+
43+ else :
44+ item .append (i )
3845
3946 if not isinstance (item , list ):
4047 item = [item ]
@@ -72,45 +79,13 @@ def get_item_from_url(url):
7279 # Search item to download
7380 account = utils .getMyPlexAccount (opts )
7481 items = search_for_item (opts .url )
75- for i in items :
76- for z in i .media :
77- for f in z .parts :
78- try :
79- # lets see if we can get the file without using pms.
80- if os .path .exists (f .file ):
81- size = os .path .getsize (f .file )
82- bar = tqdm (unit = 'B' , unit_scale = True , total = size )
83-
84- def copy (src , dest , length = 16 * 1024 ):
85- try :
86- fdest = os .path .join (dest , os .path .basename (src ))
87- with open (src , 'rb' ) as f_from :
88- with open (fdest , 'wb' ) as to :
89- while True :
90- buf = f_from .read (length )
91- bar .update (length )
92- if not buf :
93- break
94- to .write (buf )
95-
96- return fdest
97- except Exception as e :
98- raise IOError
99- finally :
100- bar .close ()
101-
102- copy (f .file , os .getcwd ())
103-
104- else :
105- raise IOError
106-
107- except IOError as e :
108- print ('Downloading from pms' )
109- # We do this manually since we dont want to add a progress to Episode etc
110- filename = '%s.%s' % (i ._prettyfilename (), f .container )
111- url = i ._server .url ('%s?download=1' % f .key )
112- filepath = utils .download (url , filename = filename , savepath = os .getcwd (),
113- session = i ._server ._session , showstatus = True )
114- print (' %s' % filepath )
82+ for item in items :
83+ for part in item .iterParts ():
84+ # We do this manually since we dont want to add a progress to Episode etc
85+ filename = '%s.%s' % (item ._prettyfilename (), part .container )
86+ url = item ._server .url ('%s?download=1' % part .key )
87+ filepath = utils .download (url , filename = filename , savepath = os .getcwd (),
88+ session = item ._server ._session , showstatus = True )
89+ #print(' %s' % filepath)
11590
11691
0 commit comments