Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version Modification (Bug and Feature Request) #1235

Closed
NicholasFlamy opened this issue Jan 2, 2024 · 20 comments
Closed

Version Modification (Bug and Feature Request) #1235

NicholasFlamy opened this issue Jan 2, 2024 · 20 comments
Labels
enhancement New feature or request

Comments

@NicholasFlamy
Copy link

Prerequisites
Done
Done
Describe the feature
So we have Version extraction RegEx for HTML, but the app I'm working with has dashes on the apk link rather than dots. Since the Match group only allows a single integer I don't know what I can do. Maybe if there was a version modification RegEx then that would be helpful. Right now I have minecraft\-pe\/(.*?)\/minecraft with Match Group as 1 but if I could modify the output and RegEx replace the dashes with dots that would work.

For new Sources, it's preferable (not required) if you suggest how the following details can be extracted from the Source in a reliable way (like an API or through web scraping):

  • The App version (or any release-specific identifier - a "pseudo-version") for the latest release
  • One or more APK URL(s) for the latest release
  • Above details for previous releases (optional)

Note that the Web scraper cannot deal with JavaScript-enabled content. -->

Describe alternatives you've considered (if applicable)
The Match Group could have RegEx. So I would set the Version Extraction RegEx to minecraft\-pe\/((\d+)-(\d+)-(\d+)-(\d+))\/minecraft and have $1.$2.$3.$4 (maybe the dots need to be escaped: $1\.$2\.$3\.$4. Maybe the Match Groups could just have a standard setup that allows entering multiple groups with a standard separator (up to you, but something like a dot or a comma) so that people could just make groups in the Version Extraction RegEx and then add them to the Match Group so that it would be easy to work with any versioning.

Note that app-specific Sources are less likely to be added. In those cases, see if the HTML Source will work for you (if not, see if a generally-applicable enhancement to the HTML Source would work, and suggest that instead). -->

Additional context
What I have now:
Screenshot_20240102_104742
Screenshot_20240102_105104

@NicholasFlamy NicholasFlamy added enhancement New feature or request to check Issue has not been reviewed labels Jan 2, 2024
@NicholasFlamy
Copy link
Author

What I described as the alternative is probably the best.

@NicholasFlamy
Copy link
Author

Also, shout out to regex101.com because I'm doing this on mobile and it's a helpful tool for testing RegEx.

@NicholasFlamy
Copy link
Author

This is kind of a bug too because the app shows that it needs an update if I hit reset install status even though the versions show up identical with the exception of the dashes vs the dots.

@OnlineCop
Copy link

OnlineCop commented Jan 2, 2024

As an example, the URL in question may look like this:
https://dl.mcpelife.com/minecraft-pe/1-20-51-01/minecraft-1-20-51-01-xbox-servers.apk

In this scenario, the version is 1-20-51-01 where there are no dots in any portion of the version, which generateStandardVersionRegExStrings() looks for.

Under the Additional Options, the regex minecraft-pe\/([0-9-]+)\/minecraft is able to extract these hyphen-separated digits from this URL, but there does not appear to be a way to convert these hyphens to dots. If a regex such as minecraft-pe\/([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)\/minecraft were used to extract digits into 4 separate groups, the Match Group to Use for Version Extraction Regex does not appear to allow anything in it except digits: 1 would indicate Group 1 only; 4 would indicate Group 4 only, but a regex like $1.$2.$3.$4 to support all 4 of the groups is not allowed.

@NicholasFlamy
Copy link
Author

Another app I'm using is modded and it reports that base app version number in Android but the download link for the apk only has the mod version. They have the base version listed on their page and I was able to use the options in the screenshots to make it work perfectly because the site has dots in the version.

Screenshot_20240102_123840_Chrome
Screenshot_20240102_124009
Screenshot_20240102_124026

@NicholasFlamy
Copy link
Author

NicholasFlamy commented Jan 2, 2024

Another app I'm using is modded and it reports that base app version number in Android but the download link for the apk only has the mod version. They have the base version listed on their page and I was able to use the options in the screenshots to make it work perfectly because the site has dots in the version.

Screenshot_20240102_123840_Chrome Screenshot_20240102_124009 Screenshot_20240102_124026

Now, I should mention, this app also gives cleartext errors anytime I click on the app in Obtainium and makes it impossible to edit the details so I have to delete and re-add to Obtainium every time but that fine because otherwise it's perfect. I might post a separate issue.
Screenshot_20240102_124052
Screenshot_20240102_124043

@NicholasFlamy
Copy link
Author

I'll add to this, the app that I originally was talking about which has the problem is Minecraft on apkvision and I know they have the version listed with dots on the page, but unlike the app that works perfectly, apkvision lists older versions as well as Beta versions so I'm hoping that it doesn't get screwed up by that. I do have Intermediate link as ^Download\ APK\ v(?!.*Beta|.*Preview|.*Mod).*$ so that it will get the normal version and I guess I could try combining this with what I have for the app that works perfectly but this seems janky.

@NicholasFlamy
Copy link
Author

I'll add to this, the app that I originally was talking about which has the problem is Minecraft on apkvision and I know they have the version listed with dots on the page, but unlike the app that works perfectly, apkvision lists older versions as well as Beta versions so I'm hoping that it doesn't get screwed up by that. I do have Intermediate link as ^Download\ APK\ v(?!.*Beta|.*Preview|.*Mod).*$ so that it will get the normal version and I guess I could try combining this with what I have for the app that works perfectly but this seems janky.

Doesn't work because I need an intermediate link and that page does not have the version so I can't do that. Maybe the version extraction could let you choose what page?

@NicholasFlamy NicholasFlamy changed the title Version Modification Version Modification (Bug and Feature Request) Jan 2, 2024
@NicholasFlamy
Copy link
Author

Also, I think Obtainium believes that 1.20.50.03 is newer than 1.20.51.01

@ImranR98
Copy link
Owner

ImranR98 commented Jan 4, 2024

Describe alternatives you've considered (if applicable)
The Match Group could have RegEx.

This is the solution I've implemented (note that it's not right to call it a "regex" since it's a custom pattern). So you'll be able to set the 'match group' field to $1.$2.$3.$4 with the version extraction regex set to (\d+)-(\d+)-(\d+)-(\d+).

This is kind of a bug too because the app shows that it needs an update if I hit reset install status even though the versions show up identical with the exception of the dashes vs the dots.

Not a bug. The whole point of version detection is to avoid having to manually correct mistakes in the version shown by Obtainium. When version detection is disabled, you are given extra buttons to manually help correct errors. Don't press 'reset install status' if you don't need to.

Also, I think Obtainium believes that 1.20.50.03 is newer than 1.20.51.01

Not a bug. As long as the versions are different, Obtainium assumes it's an update. This is because versions are not always numerical - they could be strings or some numerical system that isn't "bigger = newer". This way is more flexible.

this app also gives cleartext errors

What URL is causing that?

@ImranR98

This comment was marked as outdated.

@ImranR98 ImranR98 added TODO Issue to focus on for the next release and removed to check Issue has not been reviewed labels Jan 4, 2024
@ImranR98
Copy link
Owner

ImranR98 commented Jan 4, 2024

Nvm, the cleartext bug will also be fixed in the next release: flutter/flutter#30368

@NicholasFlamy
Copy link
Author

NicholasFlamy commented Jan 4, 2024

This is the solution I've implemented (note that it's not right to call it a "regex" since it's a custom pattern). So you'll be able to set the 'match group' field to $1.$2.$3.$4 with the version extraction regex set to (\d+)-(\d+)-(\d+)-(\d+).

If you mean that it's already implemented, I would like to add that the Match Group field forces a Numpad keyboard.
Screenshot_20240103_201631

ImranR98 added a commit that referenced this issue Jan 4, 2024
- Remove reference to old plugin to avoid crashes (#1221)
- Confirmation box for link-based imports (#1232)
- Construct extracted versions from match groups (#1235)
- Fix the WebView 'cleartext' error caused by HTTP sites (#1235)
- Make GitHub's (and Codeberg's) "fallback" work with the APK filter (#1236)
- Make version extraction universal (#1237)
- HTML Bugfix (#1238)
@ImranR98
Copy link
Owner

ImranR98 commented Jan 4, 2024

Good catch, I would have forgotten to change that.

@NicholasFlamy
Copy link
Author

NicholasFlamy commented Jan 4, 2024

I'm not sure if this is a bug so I'm posting the question. Is it intended that when doing Version Extraction RegEx, it applies to the last intermediate link page? If this is intended, I'll PR the Wiki and add this. Sometimes the original page has useful version info the intermediate does not. Maybe if we could specify a link for the Version Extraction RegEx to apply to, then that could be useful. (For example, I could apply it to the Minecraft Bedrock Release Changelogs, which are separate from the Beta changelogs (which would help in avoiding conflicts between releases and betas.) This could add complications like it not matching the version, but that's for the user, like me, to figure out. If I could specify the link to the original page then there wouldn't be any problems and if I could specify any other page that's not your problem. Also, specifying any page could be a hidden setting that's enabled in the Obtainium settings if you're worried people will bug you about it. Also, I can help a little with the documentation for everything (there's a lot that I would like to add), but I'll work on it after I'm more confident in my ability to use Obtainium.)

@ImranR98
Copy link
Owner

ImranR98 commented Jan 4, 2024

the last intermediate link page

It is meant to apply to the final APK link, not any intermediate/"middle" ones. Are you seeing different behaviour?

We could always add a "Use for Version Extraction" toggle to each intermediate link. That way the user could indicate which link to use for version detection. If all intermediate links have that toggle disabled, we would stick to current behaviour. If multiple ones have it enabled, we would pick the last one which is able to successfully extract something. Feel free to create an issue for this.

Also, I can help a little with the documentation for everything

Sure, PRs are welcome!

@ImranR98
Copy link
Owner

ImranR98 commented Jan 4, 2024

@ImranR98 ImranR98 closed this as completed Jan 4, 2024
@NicholasFlamy
Copy link
Author

It is meant to apply to the final APK link, not any intermediate/"middle" ones. Are you seeing different behaviour?

I meant with the "Apply Version Extraction Regex to Entire Page" toggle enabled.

@ImranR98
Copy link
Owner

ImranR98 commented Jan 4, 2024

In that case it should still apply to the final page on which the APK link is found. So if you're using in an intermediate link, the regex would apply not to the final intermediate link itself, but to the content of the final intermediate link page (which contains the actual returned APK link). Hope that makes sense.

@NicholasFlamy
Copy link
Author

In that case it should still apply to the final page on which the APK link is found. So if you're using an intermediate link, the regex would apply not to the final intermediate link itself, but to the content of the final intermediate link page (which contains the actual returned APK link). Hope that makes sense.

Yes, that makes sense and that is the behavior I discovered. I was suggesting any link to any page to use for the RegEx because there are cases where the apk is found on an intermediate page that doesn't contain the version. I won't have an immediate use case for this at the moment (thanks to the new implementation of Match Group), but it could come in handy.

@ImranR98 ImranR98 removed the TODO Issue to focus on for the next release label Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants