Merge pull request #73 from arabcoders/dev
Added debugpy to make easier to trace errors.
This commit is contained in:
commit
53e48c207b
6 changed files with 78 additions and 7 deletions
22
.vscode/launch.json
vendored
22
.vscode/launch.json
vendored
|
|
@ -34,6 +34,28 @@
|
|||
"YTP_URL_HOST": "http://localhost:8081",
|
||||
"YTP_LOG_LEVEL": "DEBUG"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Python: Attach To Process",
|
||||
"type": "debugpy",
|
||||
"request": "attach",
|
||||
"processId": "${command:pickProcess}",
|
||||
},
|
||||
{
|
||||
"name": "Python: Attach To Container",
|
||||
"type": "debugpy",
|
||||
"request": "attach",
|
||||
"connect": {
|
||||
"host": "localhost",
|
||||
"port": 5678
|
||||
},
|
||||
"pathMappings": [
|
||||
{
|
||||
"localRoot": "${workspaceFolder}",
|
||||
"remoteRoot": "/app/"
|
||||
}
|
||||
],
|
||||
"justMyCode": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,4 +67,6 @@ HEALTHCHECK --interval=10s --timeout=20s --start-period=10s --retries=3 CMD [ "/
|
|||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
CMD ["/app/.venv/bin/python", "/app/app/main.py"]
|
||||
ENV PYDEVD_DISABLE_FILE_VALIDATION=1
|
||||
|
||||
CMD ["/app/.venv/bin/python", "/app/app/main.py", "--ytptube-mp"]
|
||||
|
|
|
|||
1
Pipfile
1
Pipfile
|
|
@ -12,6 +12,7 @@ coloredlogs = "*"
|
|||
aiocron = "*"
|
||||
python-dotenv = "*"
|
||||
python-magic = "*"
|
||||
debugpy = "*"
|
||||
|
||||
[dev-packages]
|
||||
|
||||
|
|
|
|||
31
Pipfile.lock
generated
31
Pipfile.lock
generated
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "ff439968ef47903738a8fd477d19d86abf8650ce4c46f1f603e3f8472148ec0f"
|
||||
"sha256": "969599ea205de43f64d64331fc3307bb0d9be1dc1830c57b51f93c607d2bbe1f"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
|
|
@ -355,6 +355,35 @@
|
|||
"markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'",
|
||||
"version": "==2.0.1"
|
||||
},
|
||||
"debugpy": {
|
||||
"hashes": [
|
||||
"sha256:016a9fcfc2c6b57f939673c874310d8581d51a0fe0858e7fac4e240c5eb743cb",
|
||||
"sha256:0de56aba8249c28a300bdb0672a9b94785074eb82eb672db66c8144fff673146",
|
||||
"sha256:1a9fe0829c2b854757b4fd0a338d93bc17249a3bf69ecf765c61d4c522bb92a8",
|
||||
"sha256:28acbe2241222b87e255260c76741e1fbf04fdc3b6d094fcf57b6c6f75ce1242",
|
||||
"sha256:3a79c6f62adef994b2dbe9fc2cc9cc3864a23575b6e387339ab739873bea53d0",
|
||||
"sha256:3bda0f1e943d386cc7a0e71bfa59f4137909e2ed947fb3946c506e113000f741",
|
||||
"sha256:3ebb70ba1a6524d19fa7bb122f44b74170c447d5746a503e36adc244a20ac539",
|
||||
"sha256:58911e8521ca0c785ac7a0539f1e77e0ce2df753f786188f382229278b4cdf23",
|
||||
"sha256:6df9aa9599eb05ca179fb0b810282255202a66835c6efb1d112d21ecb830ddd3",
|
||||
"sha256:7a3afa222f6fd3d9dfecd52729bc2e12c93e22a7491405a0ecbf9e1d32d45b39",
|
||||
"sha256:7eb7bd2b56ea3bedb009616d9e2f64aab8fc7000d481faec3cd26c98a964bcdd",
|
||||
"sha256:92116039b5500633cc8d44ecc187abe2dfa9b90f7a82bbf81d079fcdd506bae9",
|
||||
"sha256:a2e658a9630f27534e63922ebf655a6ab60c370f4d2fc5c02a5b19baf4410ace",
|
||||
"sha256:bfb20cb57486c8e4793d41996652e5a6a885b4d9175dd369045dad59eaacea42",
|
||||
"sha256:caad2846e21188797a1f17fc09c31b84c7c3c23baf2516fed5b40b378515bbf0",
|
||||
"sha256:d915a18f0597ef685e88bb35e5d7ab968964b7befefe1aaea1eb5b2640b586c7",
|
||||
"sha256:dda73bf69ea479c8577a0448f8c707691152e6c4de7f0c4dec5a4bc11dee516e",
|
||||
"sha256:e38beb7992b5afd9d5244e96ad5fa9135e94993b0c551ceebf3fe1a5d9beb234",
|
||||
"sha256:edcc9f58ec0fd121a25bc950d4578df47428d72e1a0d66c07403b04eb93bcf98",
|
||||
"sha256:efd3fdd3f67a7e576dd869c184c5dd71d9aaa36ded271939da352880c012e703",
|
||||
"sha256:f696d6be15be87aef621917585f9bb94b1dc9e8aced570db1b8a6fc14e8f9b42",
|
||||
"sha256:fd97ed11a4c7f6d042d320ce03d83b20c3fb40da892f994bc041bbc415d7a099"
|
||||
],
|
||||
"index": "pypi",
|
||||
"markers": "python_version >= '3.8'",
|
||||
"version": "==1.8.1"
|
||||
},
|
||||
"frozenlist": {
|
||||
"hashes": [
|
||||
"sha256:04ced3e6a46b4cfffe20f9ae482818e34eba9b5fb0ce4056e4cc9b6e212d09b7",
|
||||
|
|
|
|||
|
|
@ -41,11 +41,13 @@ class Config:
|
|||
|
||||
version: str = APP_VERSION
|
||||
|
||||
debug: bool = False
|
||||
|
||||
new_version_available: bool = False
|
||||
|
||||
_int_vars: tuple = ('port', 'max_workers',)
|
||||
_immutable: tuple = ('version', '__instance', 'ytdl_options', 'new_version_available')
|
||||
_boolean_vars: tuple = ('keep_archive', 'ytdl_debug', 'temp_keep', 'allow_manifestless',)
|
||||
_boolean_vars: tuple = ('keep_archive', 'ytdl_debug', 'debug', 'temp_keep', 'allow_manifestless',)
|
||||
|
||||
@staticmethod
|
||||
def get_instance():
|
||||
|
|
@ -63,7 +65,9 @@ class Config:
|
|||
|
||||
self.temp_path = os.environ.get('YTP_TEMP_PATH', None) or os.path.join(baseDefaultPath, 'var', 'tmp')
|
||||
self.config_path = os.environ.get('YTP_CONFIG_PATH', None) or os.path.join(baseDefaultPath, 'var', 'config')
|
||||
self.download_path = os.environ.get('YTP_DOWNLOAD_PATH', None) or os.path.join(baseDefaultPath, 'var', 'downloads')
|
||||
self.download_path = os.environ.get(
|
||||
'YTP_DOWNLOAD_PATH', None) or os.path.join(
|
||||
baseDefaultPath, 'var', 'downloads')
|
||||
|
||||
envFile: str = os.path.join(self.config_path, '.env')
|
||||
|
||||
|
|
@ -122,6 +126,14 @@ class Config:
|
|||
|
||||
LOG = logging.getLogger('config')
|
||||
|
||||
if self.debug:
|
||||
try:
|
||||
import debugpy
|
||||
debugpy.listen(("0.0.0.0", 5678))
|
||||
LOG.info("starting debugpy server on [0.0.0.0:5678]")
|
||||
except ImportError:
|
||||
LOG.error("debugpy not found, please install it with 'pip install debugpy'")
|
||||
|
||||
optsFile: str = os.path.join(self.config_path, 'ytdlp.json')
|
||||
if os.path.exists(optsFile) and os.path.getsize(optsFile) > 0:
|
||||
LOG.info(f'Loading yt-dlp custom options from "{optsFile}"')
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ class DownloadQueue:
|
|||
if self.isDownloaded(entry):
|
||||
raise yt_dlp.utils.ExistingVideoReached()
|
||||
|
||||
LOG.debug(f'entry: extract info says: {entry}')
|
||||
LOG.debug(f'extract_info length: {len(entry)}')
|
||||
except yt_dlp.utils.ExistingVideoReached:
|
||||
return {'status': 'error', 'msg': 'Video has been downloaded already and recorded in archive.log file.'}
|
||||
except yt_dlp.utils.YoutubeDLError as exc:
|
||||
|
|
@ -345,13 +345,13 @@ class DownloadQueue:
|
|||
break
|
||||
if time.time() - lastLog > 120:
|
||||
lastLog = time.time()
|
||||
LOG.info(f'Waiting for workers to be free.')
|
||||
LOG.info(f'Waiting for worker to be free.')
|
||||
await asyncio.sleep(1)
|
||||
|
||||
LOG.debug(f"Has '{executor.get_available_workers()}' free workers.")
|
||||
|
||||
while not self.queue.hasDownloads():
|
||||
LOG.info(f'Waiting for item to download.')
|
||||
LOG.info('Waiting for item to download.')
|
||||
await self.event.wait()
|
||||
self.event.clear()
|
||||
LOG.debug(f"Cleared wait event.")
|
||||
|
|
@ -359,6 +359,9 @@ class DownloadQueue:
|
|||
entry = self.queue.getNextDownload()
|
||||
await asyncio.sleep(0.2)
|
||||
|
||||
if entry is None:
|
||||
continue
|
||||
|
||||
LOG.debug(f"Pushing {entry=} to executor.")
|
||||
|
||||
if entry.started() is False and entry.is_canceled() is False:
|
||||
|
|
@ -404,5 +407,7 @@ class DownloadQueue:
|
|||
self.done.put(value=entry)
|
||||
await self.notifier.completed(entry.info)
|
||||
|
||||
self.event.set()
|
||||
|
||||
def isDownloaded(self, info: dict) -> bool:
|
||||
return self.config.keep_archive and isDownloaded(self.config.ytdl_options.get('download_archive', None), info)
|
||||
|
|
|
|||
Loading…
Reference in a new issue