...
 
Commits (6)
V 3.3.0:
- Added download speed progress
- Fixed slow download speeds
- Fixed crashes when running without a tty
- Added --silent flag
- Added --fallback-channel option
V 3.2.0:
- Added notice that python 2 is no longer supported
- Fixed program hanging when no channels are joined
......
......@@ -38,7 +38,7 @@ def main(args: argparse.Namespace):
:return: None
"""
try:
set_logging_level(args.quiet, args.verbose, args.debug)
set_logging_level(args.quiet, args.verbose, args.debug, args.silent)
set_throttle_value(args.throttle)
search_engine = SearchEngineType.resolve(args.search_engine)
......@@ -60,7 +60,11 @@ def main(args: argparse.Namespace):
for pack in packs:
Logger().info("Downloading pack {}".format(pack))
download_packs(packs, timeout=args.timeout)
download_packs(
packs,
timeout=args.timeout,
fallback_channel=args.fallback_channel
)
except ConnectionError:
print("Connection Error, could not conduct search")
......@@ -90,6 +94,10 @@ if __name__ == "__main__":
"Append K,M or G for more convenient units")
parser.add_argument("--timeout", default=120, type=int,
help="Sets a timeout for starting the download")
parser.add_argument("--silent", action="store_true",
help="Disables all print output")
parser.add_argument("--fallback-channel",
help="Fallback channel in case ")
argparse_add_verbosity(parser)
cli_start(
main, parser,
......
......@@ -37,14 +37,18 @@ def main(args: argparse.Namespace):
"""
try:
set_throttle_value(args.throttle)
set_logging_level(args.quiet, args.verbose, args.debug)
set_logging_level(args.quiet, args.verbose, args.debug, args.silent)
packs = XDCCPack.from_xdcc_message(
args.message, os.getcwd(), args.server
)
prepare_packs(packs, args.out)
download_packs(packs, timeout=args.timeout)
download_packs(
packs,
timeout=args.timeout,
fallback_channel=args.fallback_channel
)
except DownloadIncomplete:
Logger().warning("Download incomplete.")
......@@ -71,7 +75,11 @@ if __name__ == "__main__":
"Append K,M or G for more convenient units")
parser.add_argument("--timeout", default=120, type=int,
help="Sets a timeout for starting the download")
parser.add_argument("--fallback-channel",
help="Fallback channel in case ")
argparse_add_verbosity(parser)
parser.add_argument("--silent", action="store_true",
help="Disables all print output")
cli_start(
main, parser,
sentry_dsn=sentry_dsn,
......
......@@ -35,9 +35,13 @@ def main(args: argparse.Namespace):
search_engine = SearchEngineType.resolve(args.search_engine)
results = search_engine.search(args.search_term)
for result in results:
message = "{} (xdcc-dl \"{}\")".format(result.filename, result.get_request_message(True))
message = "{} (xdcc-dl \"{}\")".format(
result.filename,
result.get_request_message(True)
)
if result.server.address != "irc.rizon.net":
message = message[0:-1] + " --server " + result.server.address + ")"
message = message[0:-1]
message += " --server " + result.server.address + ")"
print(message)
except ConnectionError:
print("Connection Error, could not conduct search")
......
3.2.0
\ No newline at end of file
3.3.0
\ No newline at end of file
......@@ -42,16 +42,19 @@ def set_throttle_value(throttle_string: str):
sys.exit(1)
def set_logging_level(quiet: bool, verbose: bool, debug: bool):
def set_logging_level(quiet: bool, verbose: bool, debug: bool, silent: bool):
"""
Sets the logging level based on a combination of flags
If all flags are False, the logging level will be set to WARNING
:param quiet: If set to True, will set logging to ERROR
:param verbose: If set to True, will set logging to INFO
:param debug: If set to True, will set logging to DEBUG
:param silent: If set to True, will disable ALL printing
:return: None
"""
if quiet:
if silent:
Logger.logging_level = -1
elif quiet:
Logger.logging_level = logging.ERROR
elif verbose:
Logger.logging_level = logging.INFO
......
......@@ -20,7 +20,7 @@ LICENSE"""
import logging
from typing import Optional
from datetime import datetime
from subprocess import check_output
from subprocess import check_output, CalledProcessError
from colorama import Fore, Back, Style
......@@ -52,6 +52,9 @@ class Logger(object):
:param end: Characters to append to the string (Default newline)
:return: None
"""
if self.logging_level == -1:
return
if level is None or self.logging_level <= level:
if self.last_end == "\r" and end != "\r":
......@@ -60,8 +63,13 @@ class Logger(object):
log_message = datetime.now().strftime("[%Y-%d-%m:%H-%M-%S]")
log_message += " " + fore + back + message
rows, columns = check_output(['stty', 'size']).split()
log_message = log_message[0:int(columns)]
try:
rows, _columns = check_output(['stty', 'size']).split()
columns = int(_columns)
except (ValueError, CalledProcessError):
columns = 80
log_message = log_message[0:columns]
print(log_message + Style.RESET_ALL, end=end)
......
This diff is collapsed.
......@@ -17,19 +17,27 @@ You should have received a copy of the GNU General Public License
along with xdcc-dl. If not, see <http://www.gnu.org/licenses/>.
LICENSE"""
from typing import List
from typing import List, Optional
from xdcc_dl.entities.XDCCPack import XDCCPack
from xdcc_dl.xdcc.XDCCClient import XDCCClient
def download_packs(packs: List[XDCCPack], timeout: int = 120):
def download_packs(
packs: List[XDCCPack],
timeout: int = 120,
fallback_channel: Optional[str] = None
):
"""
Downloads a list of XDCC Packs
:param packs: The packs to download
:param timeout: Specifies timeout time
:param fallback_channel: A fallback channel for when no channels were found
:return: None
"""
for pack in packs:
client = XDCCClient(pack, timeout=timeout)
client = XDCCClient(
pack,
timeout=timeout,
fallback_channel=fallback_channel
)
client.download()