[HUNO] Description and MediaInfo as .txt#1322
Conversation
|
Thanks for taking the time to contribute to this project. Upload Assistant is currently in a complete rewrite, and no new development is being conducted on this python source at this time. If you have come this far, please feel free to leave open, any pull requests regarding new sites being added to the source, as these can serve as the baseline for later conversion. If your pull request relates to a critical bug, this will be addressed in this code base, and a new release published as needed. If your pull request only addresses a quite minor bug, it is not likely to be addressed in this code base. Details for the new code base will follow at a later date. |
📝 WalkthroughWalkthroughThe HUNO tracker implementation has been refactored to move description and mediainfo generation from return values in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/trackers/HUNO.py`:
- Around line 163-168: Replace the direct key access meta['bdinfo'] with the
defensive lookup meta.get('bdinfo') in the HUNO.get_mediainfo (or the method
containing that mediainfo block) so it behaves like the parent
UNIT3D.get_mediainfo; specifically change the condition at the start of the
block to use meta.get('bdinfo') and keep the existing None check and downstream
logic (including calls to self.common.get_bdmv_mediainfo and file read) so a
missing bdinfo key does not raise KeyError.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
| if meta['bdinfo'] is not None: | ||
| mediainfo = await self.common.get_bdmv_mediainfo(meta, remove=['File size', 'Overall bit rate']) | ||
| else: | ||
| async with aiofiles.open(f"{meta['base_dir']}/tmp/{meta['uuid']}/MEDIAINFO_CLEANPATH.txt", encoding='utf-8') as f: | ||
| mediainfo = await f.read() | ||
| files['mediainfo'] = ('mediainfo.txt', mediainfo.encode('utf-8'), 'text/plain') |
There was a problem hiding this comment.
Use meta.get('bdinfo') for consistency with parent class.
Line 163 uses meta['bdinfo'] which will raise KeyError if the key is absent, whereas the parent UNIT3D.get_mediainfo() uses meta.get('bdinfo') with a None check. For defensive consistency:
🛡️ Proposed fix
- if meta['bdinfo'] is not None:
+ if meta.get('bdinfo') is not None:Note on static analysis S108: The /tmp/ warning is a false positive—this uses the project's {base_dir}/tmp/{uuid}/ structure, not the system temp directory.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if meta['bdinfo'] is not None: | |
| mediainfo = await self.common.get_bdmv_mediainfo(meta, remove=['File size', 'Overall bit rate']) | |
| else: | |
| async with aiofiles.open(f"{meta['base_dir']}/tmp/{meta['uuid']}/MEDIAINFO_CLEANPATH.txt", encoding='utf-8') as f: | |
| mediainfo = await f.read() | |
| files['mediainfo'] = ('mediainfo.txt', mediainfo.encode('utf-8'), 'text/plain') | |
| if meta.get('bdinfo') is not None: | |
| mediainfo = await self.common.get_bdmv_mediainfo(meta, remove=['File size', 'Overall bit rate']) | |
| else: | |
| async with aiofiles.open(f"{meta['base_dir']}/tmp/{meta['uuid']}/MEDIAINFO_CLEANPATH.txt", encoding='utf-8') as f: | |
| mediainfo = await f.read() | |
| files['mediainfo'] = ('mediainfo.txt', mediainfo.encode('utf-8'), 'text/plain') |
🧰 Tools
🪛 Ruff (0.15.7)
[error] 166-166: Probable insecure usage of temporary file or directory: "/tmp/"
(S108)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/trackers/HUNO.py` around lines 163 - 168, Replace the direct key access
meta['bdinfo'] with the defensive lookup meta.get('bdinfo') in the
HUNO.get_mediainfo (or the method containing that mediainfo block) so it behaves
like the parent UNIT3D.get_mediainfo; specifically change the condition at the
start of the block to use meta.get('bdinfo') and keep the existing None check
and downstream logic (including calls to self.common.get_bdmv_mediainfo and file
read) so a missing bdinfo key does not raise KeyError.
|
Probably the easiest method:
|
Addresses the API changes in HUNO 0.7.0.
The torrent description and MediaInfo data are now passed as
.txtfiles.There still remains the issue of the upload response. The torrent will upload successfully and correctly, but
src/trackers/UNIT3D.pyis unable to process the response in its current state.Without essentially replacing
upload(), it's not achievable to process the download URL withinsrc/trackers/HUNO.py.I would propose introducing a hook in
src/trackers/UNIT3D.pyto handle extracting thedownurlthat would allow more flexibility.At the moment,
src/trackers/UNIT3D.pyis hardcoded withdownurl=response_data["data"]that's limited to that specific format.Summary by CodeRabbit