1
0
Fork 0
mirror of https://github.com/mwalbeck/podfox.git synced 2025-04-15 10:24:10 +00:00

Added maxthreads functionality, confirmed basic implementation

This commit is contained in:
Christopher Martin 2015-11-08 16:16:24 -06:00
parent 53a4c02f9c
commit 636971f2fe
2 changed files with 16 additions and 2 deletions

View file

@ -16,7 +16,8 @@ Here is mine:
```
{
"podcast-directory" : "/home/basti/podcasts",
"maxnum" : 5
"maxnum" : 5,
"maxthreads" : 2
}
```
`podcast-directory` is your main directory to store podcast data. This directory should be empty before you

View file

@ -21,7 +21,7 @@ from colorama import Fore, Back, Style
from docopt import docopt
from os.path import expanduser
from sys import exit
from threading import Thread
from threading import Thread, active_count
import colorama
import feedparser
import json
@ -183,6 +183,11 @@ def episodes_from_feed(d):
def download_multiple(feed, maxnum):
if "maxthreads" in CONFIGURATION.keys():
maxthreads = CONFIGURATION['maxthreads']
else:
maxthreads = maxnum
for episode in feed['episodes']:
if maxnum == 0:
break
@ -193,6 +198,13 @@ def download_multiple(feed, maxnum):
#download_single(feed['shortname'], episode['url'])
episode['downloaded'] = True
maxnum -= 1
while active_count() > maxthreads:
try:
downloadthread.join(60)
except RuntimeError:
pass
overwrite_config(feed)
@ -202,6 +214,7 @@ class download_thread(Thread):
self.folder = folder
self.url = url
self.daemon = True
def run(self):
download_single(self.folder, self.url)