Merge lp:~humitos/encuentro/keep-trying-after-fail into lp:encuentro

Proposed by Facundo Batista
Status: Needs review
Proposed branch: lp:~humitos/encuentro/keep-trying-after-fail
Merge into: lp:encuentro
Diff against target: 71 lines (+18/-13)
1 file modified
encuentro/ui/central_panel.py (+18/-13)
To merge this branch: bzr merge lp:~humitos/encuentro/keep-trying-after-fail
Reviewer Review Type Date Requested Status
Facundo Batista Needs Fixing
Review via email: mp+217375@code.launchpad.net

Description of the change

Keep trying to download failed episodes

To post a comment you must log in.
Revision history for this message
Facundo Batista (facundo) wrote :

I don't like the "start from the first not downloaded after finishing the list" behaviour.

Yes, it's a good idea to retry those that failed. But what if it fails because of a non-spurious error (e.g., because the URL is wrong, or the video was removed in the backend, etc)?

In that case, the program will be in an endless loop, not only consuming local resources, but also hammering the backend services over and over again, getting the same error.

On the other hand, I like a lot the idea of marking specially the episode so it's kept after closing/opening the program. But it must not be 'waiting'... maybe something like 'failed', because of the program buttons (with 'waiting' it will not turn on the 'download' button, for example).

Maybe you could re-purpose this branch? Thanks!

review: Needs Fixing

Unmerged revisions

208. By Manuel Kaufmann

Keep trying to download failed episodes

When a download fails, Encuentro marks that episode as "State.waiting"
to try again later (once Encuentro reaches the end of the list).

All of the episodes that failed in the download process are saved to
disk when Encuentro is closed and load again when Encuentro is opened.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'encuentro/ui/central_panel.py'
2--- encuentro/ui/central_panel.py 2014-04-26 02:36:13 +0000
3+++ encuentro/ui/central_panel.py 2014-04-28 01:26:07 +0000
4@@ -1,4 +1,4 @@
5-# -*- coding: UTF-8 -*-
6+# -*- coding: utf-8 -*-
7
8 # Copyright 2013-2014 Facundo Batista
9 #
10@@ -92,7 +92,12 @@
11 """Set up everything for next download."""
12 self.downloading = True
13 self.current += 1
14- episode, _ = self.queue[self.current]
15+ try:
16+ episode, _ = self.queue[self.current]
17+ except IndexError:
18+ # get the first pending episode
19+ episode, _ = self.pending()[0]
20+ self.current = self.queue.index((episode, _))
21 episode.state = Status.downloading
22 return episode
23
24@@ -100,6 +105,7 @@
25 """Download started."""
26 episode, item = self.queue[self.current]
27 item.setText(1, u"Comenzando")
28+ item.setDisabled(False)
29 episode.state = Status.downloading
30
31 def progress(self, progress):
32@@ -117,7 +123,8 @@
33 else:
34 # something bad happened
35 gui_msg = unicode(error)
36- end_state = Status.none
37+ # mark as waiting to try again later
38+ end_state = Status.waiting
39 item.setText(1, gui_msg)
40 item.setDisabled(True)
41 episode.state = end_state
42@@ -150,21 +157,19 @@
43 self.episodes_widget.show(item.episode_id)
44
45 def pending(self):
46- """Return the pending downloads quantity (including current)."""
47- # remaining after current one
48- q = len(self.queue) - self.current - 1
49- # if we're still downloading current one, add it to the count
50- if self.downloading:
51- q += 1
52- return q
53+ pending_episodes = []
54+ for episode, item in self.queue:
55+ if episode.state in (Status.waiting, Status.none):
56+ pending_episodes.append((episode, item))
57+ return pending_episodes
58
59 def save_state(self):
60 """Save state for pending downloads."""
61- p = self.pending()
62- if p > 0:
63- pending_ids = [e.episode_id for e, _ in self.queue[-p:]]
64+ if self.pending():
65+ pending_ids = [e.episode_id for e, _ in self.pending()]
66 else:
67 pending_ids = []
68+
69 config[config.SYSTEM]['pending_ids'] = pending_ids
70
71 def load_pending(self):

Subscribers

People subscribed via source and target branches