Skip to content

Rewrite import and export subscriptions functionality using coroutines#11759

Merged
Isira-Seneviratne merged 20 commits intoTeamNewPipe:refactorfrom
Isira-Seneviratne:Import-export-worker
May 15, 2025
Merged

Rewrite import and export subscriptions functionality using coroutines#11759
Isira-Seneviratne merged 20 commits intoTeamNewPipe:refactorfrom
Isira-Seneviratne:Import-export-worker

Conversation

@Isira-Seneviratne
Copy link
Member

What is it?

  • Bugfix (user facing)
  • Feature (user facing)
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

  • Implement the subscription import/export functionality using CoroutineWorker for better performance and readability of the code.
  • Make the import process cancellable (exporting usually completes too quickly to show a notification).
  • Read/write subscription data using the Kotlinx Serialization library and plugin.
  • Update WorkManager from 2.8.1 to 2.10.0 (changelog)
  • Update the compile SDK to 35 (required by WorkManager).

Before/After Screenshots/Screen Record

Export

  • Before:
Screen_recording_20241129_071419.webm

Android 6.0

  • After:
Screen_recording_20241129_064527.webm

Android 6.0

Screen_recording_20241129_064829.mp4

Android 15

Fixes the following issue(s)

  • Fixes #

APK testing

The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR. You can find more info and a video demonstration on this wiki page.

Due diligence

@github-actions github-actions bot added the size/giant PRs with more than 750 changed lines label Nov 29, 2024
@ShareASmile ShareASmile added dependency Issues and PRs related to dependencies rewrite Issues and PRs related to rewrite import/export anything related to Import/export of data, subscriptions feature request Issue is related to a feature in the app labels Nov 29, 2024
@sonarqubecloud
Copy link

Comment on lines +50 to +56
try {
@OptIn(ExperimentalSerializationApi::class)
return json.decodeFromStream<SubscriptionData>(`in`).subscriptions
} catch (e: Throwable) {
throw InvalidSourceException("Couldn't parse json", e)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a cursory look, this seems to be a lot stricter than the previous json parser.

e.g. the serviceId would default to 0, and items in the list would simply be skipped if they don’t conform to the schema.

Do we want to change that behavior?

@Profpatsch Profpatsch force-pushed the Import-export-worker branch from e99c0bc to dbd11a6 Compare January 22, 2025 14:41
@Profpatsch
Copy link
Contributor

I rebased on current refactor, and added a commit which kotlin-ifies the SubscriptionImportWorker input data a little, turning them into a sealed class that auto-parcelizes.

Unfortunately, there is no Data.Builder().fromParcelable() or similar, so the Data conversion has to be done manually still, but I centralized it in the sealed class so it should be straightforward as well.

@Profpatsch
Copy link
Contributor

Once the missing error handling is added on import & the question about how leniently to parse the json is resolved, I’d say LGTM!

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 8, 2025

@sonarqubecloud
Copy link

Copy link
Contributor

@Profpatsch Profpatsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think we might run into issues because the json parsing is now stricter, but if you think it’s fine we can merge

@Isira-Seneviratne Isira-Seneviratne merged commit f41b34c into TeamNewPipe:refactor May 15, 2025
7 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Rewrite May 15, 2025
@Isira-Seneviratne Isira-Seneviratne deleted the Import-export-worker branch July 9, 2025 02:32
theimpulson pushed a commit to theimpulson/NewPipe that referenced this pull request Jan 26, 2026
…port-worker

Rewrite import and export subscriptions functionality using coroutines
@theimpulson theimpulson mentioned this pull request Jan 26, 2026
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependency Issues and PRs related to dependencies feature request Issue is related to a feature in the app import/export anything related to Import/export of data, subscriptions rewrite Issues and PRs related to rewrite size/giant PRs with more than 750 changed lines

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants