|
@@ -291,7 +291,7 @@ def push(pool_url, data, secret):
|
|
|
)
|
|
|
|
|
|
|
|
|
-def puller(queue, source, source_type, multiplier):
|
|
|
+def puller(queue, source, source_type, multiplier, sample_interval):
|
|
|
while True:
|
|
|
try:
|
|
|
data = sample(source, source_type, multiplier)
|
|
@@ -302,11 +302,17 @@ def puller(queue, source, source_type, multiplier):
|
|
|
except Exception as e:
|
|
|
logger.error(f"Pull exception: {e}")
|
|
|
|
|
|
+ if sample_interval:
|
|
|
+ time.sleep(sample_interval)
|
|
|
+
|
|
|
continue
|
|
|
|
|
|
for piece in chunks(data, 1024 * 500):
|
|
|
queue.put(piece)
|
|
|
|
|
|
+ if sample_interval:
|
|
|
+ time.sleep(sample_interval)
|
|
|
+
|
|
|
|
|
|
def pusher(queue, pool_url, secret, cooldown=0):
|
|
|
while True:
|
|
@@ -334,6 +340,7 @@ if __name__ == "__main__":
|
|
|
parser.add_argument("--multiplier", type=float, default=1)
|
|
|
parser.add_argument("--secret-file", type=str, default="./.secret")
|
|
|
parser.add_argument("--cooldown", type=int, default=0)
|
|
|
+ parser.add_argument("--sample-interval", type=int, default=0)
|
|
|
parser.add_argument("--pool-url", type=str, default="https://yebi.su")
|
|
|
parser.add_argument("--push-timeout", type=int, default=10)
|
|
|
parser.add_argument("--tmp-dir", type=str)
|
|
@@ -367,7 +374,7 @@ if __name__ == "__main__":
|
|
|
threading.Thread(target=video2_extractor, args=(q, q2)).start()
|
|
|
else:
|
|
|
threading.Thread(
|
|
|
- target=puller, args=(q, args.source, args.source_type, args.multiplier)
|
|
|
+ target=puller, args=(q, args.source, args.source_type, args.multiplier, args.sample_interval)
|
|
|
).start()
|
|
|
|
|
|
pusher_th = threading.Thread(
|