changed to list append, relative claim test

This commit is contained in:
Brannon King 2020-01-16 17:51:49 -07:00 committed by Lex Berezhny
parent fac28072ab
commit 47e8f74da9
3 changed files with 18 additions and 20 deletions

View file

@ -286,12 +286,9 @@ class VideoFileAnalyzer:
return file_path return file_path
if not repair: if not repair:
errors = "Streamability verification failed:\n" errors = ["Streamability verification failed:"]
for message in messages: errors.extend(filter(None, messages))
if message: raise Exception("\n ".join(errors))
errors += f" {message}\n"
raise Exception(errors)
# the plan for transcoding: # the plan for transcoding:
# we have to re-encode the video if it is in a nonstandard format # we have to re-encode the video if it is in a nonstandard format
@ -299,34 +296,35 @@ class VideoFileAnalyzer:
# we also re-encode if our bitrate is too high # we also re-encode if our bitrate is too high
try: try:
transcode_command = f'-i "{file_path}" -y -c:s copy -c:d copy -c:v ' transcode_command = [f'-i "{file_path}" -y -c:s copy -c:d copy -c:v']
video_encoder = "" video_encoder = ""
if video_msg or bitrate_msg: if video_msg or bitrate_msg:
video_encoder = await self._get_video_encoder(scan_data) video_encoder = await self._get_video_encoder(scan_data)
transcode_command += f"{video_encoder} " transcode_command.append(video_encoder)
else: else:
transcode_command += "copy " transcode_command.append("copy")
transcode_command += "-movflags +faststart -c:a " transcode_command.append("-movflags +faststart -c:a")
path = pathlib.Path(file_path) path = pathlib.Path(file_path)
extension = self._get_best_container_extension(scan_data, video_encoder) extension = self._get_best_container_extension(scan_data, video_encoder)
if audio_msg or volume_msg: if audio_msg or volume_msg:
audio_encoder = await self._get_audio_encoder(extension) audio_encoder = await self._get_audio_encoder(extension)
transcode_command += f"{audio_encoder} " transcode_command.append(audio_encoder)
if volume_msg: if volume_msg:
volume_filter = await self._get_volume_filter() volume_filter = await self._get_volume_filter()
transcode_command += f"{volume_filter} " transcode_command.append(volume_filter)
else: else:
transcode_command += "copy " transcode_command.append("copy")
# TODO: put it in a temp folder and delete it after we upload? # TODO: put it in a temp folder and delete it after we upload?
output = path.parent / f"{path.stem}_fixed.{extension}" output = path.parent / f"{path.stem}_fixed.{extension}"
transcode_command += f'"{output}"' transcode_command.append(f'"{output}"')
log.info("Proceeding on transcode via: ffmpeg %s", transcode_command) ffmpeg_command = " ".join(transcode_command)
result, code = await self._execute("ffmpeg", transcode_command) log.info("Proceeding on transcode via: ffmpeg %s", ffmpeg_command)
result, code = await self._execute("ffmpeg", ffmpeg_command)
if code != 0: if code != 0:
raise Exception(f"Failure to complete the transcode command. Output: {result}") raise Exception(f"Failure to complete the transcode command. Output: {result}")
except Exception as e: except Exception as e:

View file

@ -5,7 +5,7 @@ import time
import lbry.wallet # just to make the following line work: import lbry.wallet # just to make the following line work:
from lbry.conf import TranscodeConfig from lbry.conf import TranscodeConfig
from lbry.file_analysis import VideoFileAnalyzer from lbry.file_analysis import VideoFileAnalyzer
from tests.integration.blockchain.test_claim_commands import ClaimTestCase from .test_claim_commands import ClaimTestCase
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -146,4 +146,3 @@ class TranscodeValidation(ClaimTestCase):
await self.analyzer.verify_or_repair(True, False, self.video_file_name) await self.analyzer.verify_or_repair(True, False, self.video_file_name)
finally: finally:
self.conf.ffmpeg_folder = "" self.conf.ffmpeg_folder = ""

View file

@ -199,8 +199,9 @@ class WalletEncryptionAndSynchronization(CommandTestCase):
await self.confirm_tx(sendtxid, self.daemon2.ledger) await self.confirm_tx(sendtxid, self.daemon2.ledger)
def assertWalletEncrypted(self, wallet_path, encrypted): def assertWalletEncrypted(self, wallet_path, encrypted):
wallet = json.load(open(wallet_path)) with open(wallet_path) as opened:
self.assertEqual(wallet['accounts'][0]['private_key'][1:4] != 'prv', encrypted) wallet = json.load(opened)
self.assertEqual(wallet['accounts'][0]['private_key'][1:4] != 'prv', encrypted)
async def test_sync(self): async def test_sync(self):
daemon, daemon2 = self.daemon, self.daemon2 daemon, daemon2 = self.daemon, self.daemon2