Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
lasers
NewPipeExtractor
Commits
7ae274b2
Commit
7ae274b2
authored
Sep 11, 2017
by
Mauricio Colli
Browse files
Fix uploader name when requesting next streams
parent
bd3db340
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java
View file @
7ae274b2
...
...
@@ -34,12 +34,12 @@ import java.util.ArrayList;
public
class
ChannelInfo
extends
ListInfo
{
public
static
NextItemsResult
getMoreItems
(
ServiceList
serviceItem
,
String
nextStreamsUrl
)
throws
IOException
,
ExtractionException
{
return
getMoreItems
(
serviceItem
.
getService
(),
nextStreamsUrl
);
public
static
NextItemsResult
getMoreItems
(
ServiceList
serviceItem
,
String
url
,
String
nextStreamsUrl
)
throws
IOException
,
ExtractionException
{
return
getMoreItems
(
serviceItem
.
getService
(),
url
,
nextStreamsUrl
);
}
public
static
NextItemsResult
getMoreItems
(
StreamingService
service
,
String
nextStreamsUrl
)
throws
IOException
,
ExtractionException
{
return
service
.
getChannelExtractor
(
nul
l
,
nextStreamsUrl
).
getNextStreams
();
public
static
NextItemsResult
getMoreItems
(
StreamingService
service
,
String
url
,
String
nextStreamsUrl
)
throws
IOException
,
ExtractionException
{
return
service
.
getChannelExtractor
(
ur
l
,
nextStreamsUrl
).
getNextStreams
();
}
public
static
ChannelInfo
getInfo
(
String
url
)
throws
IOException
,
ExtractionException
{
...
...
src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java
View file @
7ae274b2
...
...
@@ -14,12 +14,12 @@ import java.util.ArrayList;
public
class
PlaylistInfo
extends
ListInfo
{
public
static
NextItemsResult
getMoreItems
(
ServiceList
serviceItem
,
String
nextStreamsUrl
)
throws
IOException
,
ExtractionException
{
return
getMoreItems
(
serviceItem
.
getService
(),
nextStreamsUrl
);
public
static
NextItemsResult
getMoreItems
(
ServiceList
serviceItem
,
String
url
,
String
nextStreamsUrl
)
throws
IOException
,
ExtractionException
{
return
getMoreItems
(
serviceItem
.
getService
(),
url
,
nextStreamsUrl
);
}
public
static
NextItemsResult
getMoreItems
(
StreamingService
service
,
String
nextStreamsUrl
)
throws
IOException
,
ExtractionException
{
return
service
.
getPlaylistExtractor
(
nul
l
,
nextStreamsUrl
).
getNextStreams
();
public
static
NextItemsResult
getMoreItems
(
StreamingService
service
,
String
url
,
String
nextStreamsUrl
)
throws
IOException
,
ExtractionException
{
return
service
.
getPlaylistExtractor
(
ur
l
,
nextStreamsUrl
).
getNextStreams
();
}
public
static
PlaylistInfo
getInfo
(
String
url
)
throws
IOException
,
ExtractionException
{
...
...
src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractor.java
View file @
7ae274b2
...
...
@@ -45,8 +45,6 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
private
static
final
String
CHANNEL_FEED_BASE
=
"https://www.youtube.com/feeds/videos.xml?channel_id="
;
private
static
final
String
CHANNEL_URL_PARAMETERS
=
"/videos?view=0&flow=list&sort=dd&live_view=10000"
;
private
String
channelName
=
""
;
//Small hack used to make the channelName available to NextStreams
private
Document
doc
;
/**
* It's lazily initialized (when getNextStreams is called)
...
...
@@ -69,6 +67,13 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
nextStreamsAjax
=
null
;
}
@Override
protected
boolean
fetchPageUponCreation
()
{
// Unfortunately, we have to fetch the page even if we are getting only next streams,
// as they don't deliver enough information on their own (the channel name, for example).
return
true
;
}
@Override
public
String
getCleanUrl
()
{
try
{
...
...
@@ -93,8 +98,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
@Override
public
String
getName
()
throws
ParsingException
{
try
{
channelName
=
doc
.
select
(
"span[class=\"qualified-channel-title-text\"]"
).
first
().
select
(
"a"
).
first
().
text
();
return
channelName
;
return
doc
.
select
(
"meta[property=\"og:title\"]"
).
first
().
attr
(
"content"
);
}
catch
(
Exception
e
)
{
throw
new
ParsingException
(
"Could not get channel name"
,
e
);
}
...
...
@@ -204,10 +208,10 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
}
}
private
void
collectStreamsFrom
(
StreamInfoItemCollector
collector
,
Element
element
)
throws
ParsingException
{
private
void
collectStreamsFrom
(
StreamInfoItemCollector
collector
,
Element
element
)
throws
ParsingException
{
collector
.
getItemList
().
clear
();
final
String
uploaderName
=
getName
();
for
(
final
Element
li
:
element
.
children
())
{
if
(
li
.
select
(
"div[class=\"feed-item-dismissable\"]"
).
first
()
!=
null
)
{
collector
.
commit
(
new
YoutubeStreamInfoItemExtractor
(
li
)
{
...
...
@@ -235,11 +239,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
@Override
public
String
getUploaderName
()
throws
ParsingException
{
if
(
channelName
.
isEmpty
())
{
return
""
;
}
else
{
return
channelName
;
}
return
uploaderName
;
}
@Override
...
...
src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java
View file @
7ae274b2
...
...
@@ -6,7 +6,6 @@ import org.schabi.newpipe.Downloader;
import
org.schabi.newpipe.extractor.ListExtractor
;
import
org.schabi.newpipe.extractor.NewPipe
;
import
org.schabi.newpipe.extractor.channel.ChannelExtractor
;
import
org.schabi.newpipe.extractor.stream.StreamInfoItem
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
schabi
.
newpipe
.
extractor
.
ServiceList
.
YouTube
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment