Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(verbose): Adding verbose mode #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions upodder/upodder.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
help='Import feeds from an OPML file.')
parser.add_argument("--quiet", help="Only output errors.",
action="store_true")
parser.add_argument('--verbose', action='store_true',
help="Ask user for confirmation before downloading each episode.")
args = parser.parse_args()

YES = [1,"1","on","yes","Yes","YES","y","Y","true","True","TRUE","t","T"]
Expand Down Expand Up @@ -115,6 +117,11 @@ def _download_enclosure(self, enclosure, entry, feed, no_download=False):
"""Downloads URL to file, returns file name of download (from URL or Content-Disposition)"""
if not os.path.exists(os.path.dirname(downloadto)):
os.makedirs(os.path.dirname(downloadto))

if args.verbose:
user_wish_to_download = input("Would you like to download " + entry['title'] +"? (y/n) or quit? (Ctrl+c): ")
if user_wish_to_download not in YES:
return True

l.debug("Downloading %s from %s" % (entry['title'], enclosure['href']))
r = requests.get(enclosure['href'], stream=True, timeout=25)
Expand Down