File tree Expand file tree Collapse file tree
extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2222import javax .annotation .Nonnull ;
2323
2424public class YoutubeFeedExtractor extends FeedExtractor {
25+ private static final String WEBSITE_CHANNEL_BASE_URL = "https://www.youtube.com/channel/" ;
26+
2527 public YoutubeFeedExtractor (final StreamingService service , final ListLinkHandler linkHandler ) {
2628 super (service , linkHandler );
2729 }
@@ -57,19 +59,40 @@ public ListExtractor.InfoItemsPage<StreamInfoItem> getInitialPage() {
5759 @ Nonnull
5860 @ Override
5961 public String getId () {
60- return document . getElementsByTag ( "yt:channelId" ). first (). text ( );
62+ return getUrl (). replace ( WEBSITE_CHANNEL_BASE_URL , "" );
6163 }
6264
6365 @ Nonnull
6466 @ Override
6567 public String getUrl () {
66- return document .select ("feed > author > uri" ).first ().text ();
68+ final Element authorUriElement = document .select ("feed > author > uri" )
69+ .first ();
70+ if (authorUriElement != null ) {
71+ final String authorUriElementText = authorUriElement .text ();
72+ if (!authorUriElementText .equals ("" )) {
73+ return authorUriElementText ;
74+ }
75+ }
76+
77+ final Element linkElement = document .select ("feed > link[rel*=alternate]" )
78+ .first ();
79+ if (linkElement != null ) {
80+ return linkElement .attr ("href" );
81+ }
82+
83+ return "" ;
6784 }
6885
6986 @ Nonnull
7087 @ Override
7188 public String getName () {
72- return document .select ("feed > author > name" ).first ().text ();
89+ final Element nameElement = document .select ("feed > author > name" )
90+ .first ();
91+ if (nameElement == null ) {
92+ return "" ;
93+ }
94+
95+ return nameElement .text ();
7396 }
7497
7598 @ Override
You can’t perform that action at this time.
0 commit comments