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

Add support for channel tabs #9182

Merged
merged 50 commits into from
Sep 18, 2023
Merged

Add support for channel tabs #9182

merged 50 commits into from
Sep 18, 2023

Conversation

Theta-Dev
Copy link
Contributor

@Theta-Dev Theta-Dev commented Oct 23, 2022

What is it?

  • Feature (user facing)

Description of the changes in your PR

Because YouTube is planning to update their channel page layout (as announced here) and divide videos into 3 tabs (regular videos, shorts, livestreams), we need to add this layout to the NewPipe app to be able to access all channel content.

This PR adds a tabbed channel layout with tabs for videos, shorts, livestreams, playlists, featured channels and channel info and a setting to hide certain channel tabs.

Before/After Screenshots/Screen Record

https://libreddit.kavin.rocks/r/NewPipe/comments/ybvl5t/update_on_the_channel_tabs_feature_debug_apk/

Fixes the following issue(s)

Relies on the following changes

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.

Old versions
  • app-debug.zip
  • app-debug2.zip (update: merged the latest extractor commits, fixes like count extraction)
  • app-debug3.zip (update: cache channel data, fix NPE crash, add Bandcamp album support)
  • app-debug4.zip (update: small extractor bugfix, extract upload date from shorts (edit: this info not returned anymore for shorts on the corresponding channel tab), show albums from YouTube Music artist channels)
  • app-debug5.zip (update: show channel header regardless of channel tab, collapsed when scrolling down)
  • app-debug6.zip (update: correct channel header theme)
  • APK signed by Stypox: app-debug.zip.

Due diligence

@opusforlife2
Copy link
Collaborator

Dun dun DUUUUUUUN. It's happening. It's finally happening. ಥ‿ಥ

@opusforlife2
Copy link
Collaborator

Opening non-video items in channel tabs and then going back causes the entire channel info to be loaded again. Can it not be cached? Or opened as a fragment or something like video details pages are?


Crash crash crash! If you open any item from a non-video channel tab and then open a video, going full screen causes this crash:

FATAL EXCEPTION: main
Process: org.schabi.newpipe.debug.channeltabs, PID: 17217
java.lang.NullPointerException: Attempt to read from field 'com.google.android.material.tabs.TabLayout org.schabi.newpipe.databinding.FragmentChannelBinding.tabLayout' on a null object reference
	at org.schabi.newpipe.fragments.list.channel.ChannelFragment.onSaveInstanceState(ChannelFragment.java:134)
	at androidx.fragment.app.Fragment.performSaveInstanceState(Fragment.java:3183)
	at androidx.fragment.app.FragmentStateManager.saveBasicState(FragmentStateManager.java:680)
	at androidx.fragment.app.FragmentStateManager.saveState(FragmentStateManager.java:646)
	at androidx.fragment.app.FragmentStore.saveActiveFragments(FragmentStore.java:214)
	at androidx.fragment.app.FragmentManager.saveAllStateInternal(FragmentManager.java:2318)
	at androidx.fragment.app.FragmentManager.lambda$attachController$0$androidx-fragment-app-FragmentManager(FragmentManager.java:2572)
	at androidx.fragment.app.FragmentManager$$ExternalSyntheticLambda0.saveState(Unknown Source:2)
	at androidx.savedstate.SavedStateRegistry.performSave(SavedStateRegistry.kt:247)
	at androidx.savedstate.SavedStateRegistryController.performSave(SavedStateRegistryController.kt:81)
	at androidx.activity.ComponentActivity.onSaveInstanceState(ComponentActivity.java:338)
	at android.app.Activity.performSaveInstanceState(Activity.java:2203)
	at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1520)
	at android.app.ActivityThread.callActivityOnSaveInstanceState(ActivityThread.java:5830)
	at android.app.ActivityThread.callActivityOnStop(ActivityThread.java:5229)
	at android.app.ActivityThread.handleRelaunchActivityInner(ActivityThread.java:5784)
	at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:5703)
	at android.app.servertransaction.ActivityRelaunchItem.execute(ActivityRelaunchItem.java:71)
	at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2253)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loopOnce(Looper.java:201)
	at android.os.Looper.loop(Looper.java:288)
	at android.app.ActivityThread.main(ActivityThread.java:7870)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

@TobiGr TobiGr added feature request Issue is related to a feature in the app GUI Issue is related to the graphical user interface multiservice Issues related to multiple services deep review required Maintainer must double check/test/review this due to changes in API or architecture labels Oct 24, 2022
@Theta-Dev
Copy link
Contributor Author

@opusforlife2 I published a new debug build (v3) that should fix your issues

@opusforlife2
Copy link
Collaborator

Confirmed. Thanks!

@SameenAhnaf

This comment was marked as off-topic.

@tvnmguy
Copy link

tvnmguy commented Oct 29, 2022

Some design suggestion for new channel tabs! img_2022_10_29_12_26_15.jpg IMG_20221025_101021.jpg IMG_20221025_101613.jpg IMG_20221025_100719.jpg IMG_20221025_102008.jpg session-2022-10-25-110503.jpg IMG_20221029_105634.jpg

Some channels doesn't feature Home video, then the Home tab look like this👇

img_2022_10_29_12_33_54.jpg

@tvnmguy
Copy link

tvnmguy commented Oct 29, 2022

Is possible to implement search something in a channel? If possible... My design is here👇 img_2022_10_29_13_23_48.jpg IMG_20221029_131703.jpg img_2022_10_29_13_23_48.jpg img_2022_10_29_13_08_48.jpg img_2022_10_29_13_05_50.jpg img_2022_10_29_13_01_56.jpg

@Theta-Dev
Copy link
Contributor Author

@SameenAhnaf Did you open this playlist from the channel playlists tab? I tried it and could not reproduce this issue.

This PR does not touch any playlist extraction code, so that issue may also occur when opening a playlist manually.

A quick fix would be to clear the cache and reopen the playlist.

@SameenAhnaf
Copy link
Collaborator

SameenAhnaf commented Oct 29, 2022

@Theta-Dev AudricV successfully solved the bug in extractor. Anyway, #5746 & #9223 could be linked with this PR.

Btw, do you have any plan how to integrate 3 separate tabs' loading into one what's new feed? Or, split what's new feed into three tabs on another PR? I noticed that recent shorts and live videos are not included in what's new feed.

@Theta-Dev
Copy link
Contributor Author

Theta-Dev commented Oct 29, 2022

It is not possible to merge all 3 tabs into one feed because YouTube does not show the upload date of shorts.

We could omit the shorts and merge the video and livestream tab into the feed.

An alternative would be to fetch both the video tab and the RSS feed. That would be faster than fetching 2 tabs and we would still get all the shorts and livestreams

@SameenAhnaf
Copy link
Collaborator

SameenAhnaf commented Oct 29, 2022

Is it within scope of this PR to split what's new feed into three tabs? An issue is inevitable in this regard.

An alternative would be to fetch both the video tab and the RSS feed.

I think, this point should be discussed in #4934 instead. Many users have limited access to cellular data and this should be an option, not the only way.

@opusforlife2
Copy link
Collaborator

I haven't set the visitor data cookie, yet I'm suddenly seeing the Shorts and Live tabs. I wasn't seeing them a couple of days ago when I tested debug3. A/B testing is the culprit, I assume?

@killerrook
Copy link

App debug 3 is working all right even without entering any cookie no problem during video playback using it instead of official new pipe release for 3 days

@killerrook
Copy link

killerrook commented Nov 1, 2022

If the app remains open and android goes in deep sleep or app is killed by android. The following error shows up 4-5 times. Then keep pressing back and app will be closed after all error reports are shown. Upon reopening it will work fine again. Consistent issue.Hope that helps.

Exception

  • User Action: ui error
  • Request: ACRA report
  • Content Country: US
  • Content Language: en-US
  • App Language: en_US
  • Service: none
  • Version: 0.24.0
  • OS: Linux OPPO/CPH1861/CPH1861:9/PPR1.180610.011/1587903909:user/release-keys 9 - 28
Crash log

java.lang.RuntimeException: Unable to start activity ComponentInfo{org.schabi.newpipe.debug.channeltabs/org.schabi.newpipe.MainActivity}: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: androidx.fragment.app.FragmentManagerState
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3175)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3312)
	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:113)
	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:71)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2038)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loop(Looper.java:226)
	at android.app.ActivityThread.main(ActivityThread.java:7178)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:503)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:942)
Caused by: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: androidx.fragment.app.FragmentManagerState
	at android.os.Parcel.readParcelableCreator(Parcel.java:2855)
	at android.os.Parcel.readParcelable(Parcel.java:2781)
	at android.os.Parcel.readValue(Parcel.java:2684)
	at android.os.Parcel.readArrayMapInternal(Parcel.java:3053)
	at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:288)
	at android.os.BaseBundle.unparcel(BaseBundle.java:232)
	at android.os.Bundle.getParcelable(Bundle.java:940)
	at androidx.fragment.app.FragmentManager.attachController(FragmentManager.java:2583)
	at androidx.fragment.app.FragmentController.attachHost(FragmentController.java:116)
	at androidx.fragment.app.FragmentActivity.lambda$init$1$androidx-fragment-app-FragmentActivity(FragmentActivity.java:128)
	at androidx.fragment.app.FragmentActivity$$ExternalSyntheticLambda1.onContextAvailable(Unknown Source:2)
	at androidx.activity.contextaware.ContextAwareHelper.dispatchOnContextAvailable(ContextAwareHelper.java:99)
	at androidx.activity.ComponentActivity.onCreate(ComponentActivity.java:322)
	at androidx.fragment.app.FragmentActivity.onCreate(FragmentActivity.java:249)
	at org.schabi.newpipe.MainActivity.onCreate(MainActivity.java:136)
	at android.app.Activity.performCreate(Activity.java:7383)
	at android.app.Activity.performCreate(Activity.java:7374)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3155)
	... 11 more


@WorkHard4470

This comment was marked as off-topic.

@killerrook

This comment was marked as off-topic.

@heberjeur heberjeur mentioned this pull request Nov 5, 2022
6 tasks
@SameenAhnaf
Copy link
Collaborator

Channel tabs seem to be inaccessible if added as a content on main page. Only, normal videos are shown.

@Theta-Dev
Copy link
Contributor Author

Channel tabs seem to be inaccessible if added as a content on main page. Only, normal videos are shown.

That is intentional. The main page already used a tabbed layout, so we cant have another tab bar inside.

@tsiflimagas
Copy link
Contributor

One thing I noticed is that when being on any tab other than the "VIDEOS" one, if you rotate the screen, you're moved back to it (the videos tab).

@WorkHard4470

This comment was marked as spam.

@c0h2r

This comment was marked as off-topic.

@killerrook

This comment was marked as off-topic.

@killerrook

This comment was marked as off-topic.

Theta-Dev and others added 22 commits September 18, 2023 23:22
Now the placeholder gets hidden if there is no banner url or the user disabled images, to save space
YouTube's "Desktop Max" thumbnails are 2560x423, while our previous placeholder banner was 2550x427. The extractor actually returns a lower resolution "Desktop Max" banner at 1060x175, but the ratio wrt 2560x423 is off by ~0.1%

The PNG was optimized with OptiPNG
Since it is embedded in the app bar and has red as background color, it should be themed in the same way as the toolbar.
This empty element should be always hidden for this tab, as there is no upload
date available for channels.
The breakage of these tests is related to the channel tabs changes.

The testRememberRecentStreams test method has been removed, as it doesn't seem
to be relevant anymore to managing subscriptions.
Add the separate utility class PlayButtonHelper to handle the initialization of the listeners.
The ClickListeners on playlist controls had different behaviours. This commit fixes that.

The commit also refactors the way how the app determines whether it is started for the first time. The previous version was not clean and recent in this PR caused it to fail.
Co-Authored-By:  Audric V <[email protected]>
Copy link
Contributor

@TobiGr TobiGr left a comment

Choose a reason for hiding this comment

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

We were not able to reproduce @Feuerswut's crash and assume that it was caused by an unsupported backup version. The goal is to merge this PR and get the changes into the nightlies to reach a broader testing audience.

@AudricV
Copy link
Member

AudricV commented Sep 18, 2023

Shorts do not seem to be fetched in my feed, did we decide to just ignore those? We should probably show a warning if that's the case, and remove the entry from the "Fetch channel tabs" setting

No, that's because the extractor version is old and has the bug described in TeamNewPipe/NewPipeExtractor#1077.

Maybe we might want to merge the "Channels" tab with the "About" tab. Related channels are not really a content of the channel, but rather a metadata item, and as such they are used less frequently and in my opinion would fit better in its section in the "About" tab. This would also reduce the amount of tabs by 1, making scrolling simpler.

I tend to disagree, as theoretically, a channel could have hundreds of related channels, which would fit better in a separate tab in this case.

The shorts playlist workaround doesn't allow us to fetch shorts upload dates anymore, right? YouTube removed dates there too. Do we want to try with the Smart TV client as suggested here?

No, see TeamNewPipe/NewPipeExtractor#1077 for a discussion and reasons around that.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 4 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@Stypox Stypox merged commit 0eae9e7 into TeamNewPipe:dev Sep 18, 2023
4 of 6 checks passed
@opusforlife2
Copy link
Collaborator

We should mark this historic day by making it an international holiday, I say.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deep review required Maintainer must double check/test/review this due to changes in API or architecture feature request Issue is related to a feature in the app GUI Issue is related to the graphical user interface multiservice Issues related to multiple services
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Support for Channel Tabs