|
@@ -377,6 +377,8 @@ def get_parser():
|
|
|
"--sort-by", default="no", type=str, choices=("random", "date", "duration")
|
|
|
)
|
|
|
filters.add_argument(
|
|
|
+ '--random-seed', default=None, help='Initialize the random generator. For debug only')
|
|
|
+ filters.add_argument(
|
|
|
"--reverse", default=False, action="store_true", help="Reverse list order"
|
|
|
)
|
|
|
|
|
@@ -526,20 +528,14 @@ def audio_passes_filters(audio, args):
|
|
|
return True
|
|
|
|
|
|
|
|
|
-def main():
|
|
|
- parser = get_parser()
|
|
|
- args = parser.parse_args()
|
|
|
- if not args.debug:
|
|
|
- logging.basicConfig(level=logging.WARNING)
|
|
|
- else:
|
|
|
- logging.basicConfig(level=logging.DEBUG)
|
|
|
+def get_audio_by_source(args, parser):
|
|
|
sources = args.urls
|
|
|
-
|
|
|
if args.source_weights:
|
|
|
weights = list(map(int, args.source_weights.split(":")))
|
|
|
if len(weights) != len(sources):
|
|
|
parser.exit(
|
|
|
- status=2, message="Weight must be in the" " same number as sources\n"
|
|
|
+ status=2,
|
|
|
+ message="Weight must be in the same number as sources\n",
|
|
|
)
|
|
|
else:
|
|
|
weights = [1] * len(sources)
|
|
@@ -556,6 +552,20 @@ def main():
|
|
|
if sum(weights) == 0:
|
|
|
return
|
|
|
sources = [weighted_choice(sources, weights)]
|
|
|
+ return audio_by_source, sources
|
|
|
+
|
|
|
+
|
|
|
+def main():
|
|
|
+ parser = get_parser()
|
|
|
+ args = parser.parse_args()
|
|
|
+ if not args.debug:
|
|
|
+ logging.basicConfig(level=logging.WARNING)
|
|
|
+ else:
|
|
|
+ logging.basicConfig(level=logging.DEBUG)
|
|
|
+ if args.random_seed is not None:
|
|
|
+ random.seed(args.random_seed)
|
|
|
+
|
|
|
+ audio_by_source, sources = get_audio_by_source(args, parser)
|
|
|
|
|
|
audios = []
|
|
|
for source_url in sources:
|