|
3 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; |
4 | 4 | import static org.schabi.newpipe.extractor.ServiceList.YouTube; |
5 | 5 | import static org.schabi.newpipe.extractor.services.DefaultTests.assertNoMoreItems; |
| 6 | +import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestMoreItems; |
6 | 7 | import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems; |
7 | 8 |
|
8 | 9 | import org.junit.jupiter.api.Test; |
9 | 10 | import org.schabi.newpipe.extractor.exceptions.ParsingException; |
10 | 11 | import org.schabi.newpipe.extractor.services.BaseListExtractorTest; |
11 | 12 | import org.schabi.newpipe.extractor.services.DefaultSimpleExtractorTest; |
| 13 | +import org.schabi.newpipe.extractor.services.youtube.extractors.kiosk.YoutubeLiveExtractor; |
12 | 14 | import org.schabi.newpipe.extractor.services.youtube.extractors.kiosk.YoutubeTrendingExtractor; |
| 15 | +import org.schabi.newpipe.extractor.services.youtube.extractors.kiosk.YoutubeTrendingGamingVideosExtractor; |
| 16 | +import org.schabi.newpipe.extractor.services.youtube.extractors.kiosk.YoutubeTrendingMoviesAndShowsTrailersExtractor; |
| 17 | +import org.schabi.newpipe.extractor.services.youtube.extractors.kiosk.YoutubeTrendingMusicExtractor; |
| 18 | +import org.schabi.newpipe.extractor.services.youtube.extractors.kiosk.YoutubeTrendingPodcastsEpisodesExtractor; |
13 | 19 |
|
14 | 20 | public class YoutubeKioskExtractorTest { |
15 | 21 |
|
@@ -63,4 +69,280 @@ public void testMoreRelatedItems() throws Exception { |
63 | 69 | assertNoMoreItems(extractor()); |
64 | 70 | } |
65 | 71 | } |
| 72 | + |
| 73 | + public static class Live extends DefaultSimpleExtractorTest<YoutubeLiveExtractor> |
| 74 | + implements BaseListExtractorTest, InitYoutubeTest { |
| 75 | + @Override |
| 76 | + protected YoutubeLiveExtractor createExtractor() throws Exception { |
| 77 | + return (YoutubeLiveExtractor) YouTube.getKioskList().getExtractorById( |
| 78 | + "live", null); |
| 79 | + } |
| 80 | + |
| 81 | + @Override |
| 82 | + @Test |
| 83 | + public void testServiceId() { |
| 84 | + assertEquals(YouTube.getServiceId(), extractor().getServiceId()); |
| 85 | + } |
| 86 | + |
| 87 | + @Override |
| 88 | + @Test |
| 89 | + public void testName() throws Exception { |
| 90 | + assertEquals("Live", extractor().getName()); |
| 91 | + } |
| 92 | + |
| 93 | + @Override |
| 94 | + @Test |
| 95 | + public void testId() throws Exception { |
| 96 | + assertEquals("live", extractor().getId()); |
| 97 | + } |
| 98 | + |
| 99 | + @Override |
| 100 | + @Test |
| 101 | + public void testUrl() throws Exception { |
| 102 | + assertEquals( |
| 103 | + "https://www.youtube.com/channel/UC4R8DWoMoI7CAwX8_LjQHig/livetab?ss=CKEK", |
| 104 | + extractor().getUrl()); |
| 105 | + } |
| 106 | + |
| 107 | + @Override |
| 108 | + @Test |
| 109 | + public void testOriginalUrl() throws Exception { |
| 110 | + assertEquals( |
| 111 | + "https://www.youtube.com/channel/UC4R8DWoMoI7CAwX8_LjQHig/livetab?ss=CKEK", |
| 112 | + extractor().getOriginalUrl()); |
| 113 | + } |
| 114 | + |
| 115 | + @Override |
| 116 | + @Test |
| 117 | + public void testRelatedItems() throws Exception { |
| 118 | + // As there is sometimes very recently ended livestreams present, we can't test whether |
| 119 | + // all streams are running live streams |
| 120 | + defaultTestRelatedItems(extractor()); |
| 121 | + } |
| 122 | + |
| 123 | + @Override |
| 124 | + @Test |
| 125 | + public void testMoreRelatedItems() throws Exception { |
| 126 | + defaultTestMoreItems(extractor()); |
| 127 | + } |
| 128 | + } |
| 129 | + |
| 130 | + public static class TrendingPodcastsEpisodes extends |
| 131 | + DefaultSimpleExtractorTest<YoutubeTrendingPodcastsEpisodesExtractor> |
| 132 | + implements BaseListExtractorTest, InitYoutubeTest { |
| 133 | + @Override |
| 134 | + protected YoutubeTrendingPodcastsEpisodesExtractor createExtractor() throws Exception { |
| 135 | + return (YoutubeTrendingPodcastsEpisodesExtractor) YouTube.getKioskList() |
| 136 | + .getExtractorById("trending_podcasts_episodes", null); |
| 137 | + } |
| 138 | + |
| 139 | + @Override |
| 140 | + @Test |
| 141 | + public void testServiceId() { |
| 142 | + assertEquals(YouTube.getServiceId(), extractor().getServiceId()); |
| 143 | + } |
| 144 | + |
| 145 | + @Override |
| 146 | + @Test |
| 147 | + public void testName() throws Exception { |
| 148 | + // The name is the title of channel and not of the section |
| 149 | + assertEquals("Podcasts", extractor().getName()); |
| 150 | + } |
| 151 | + |
| 152 | + @Override |
| 153 | + @Test |
| 154 | + public void testId() throws Exception { |
| 155 | + assertEquals("trending_podcasts_episodes", extractor().getId()); |
| 156 | + } |
| 157 | + |
| 158 | + @Override |
| 159 | + @Test |
| 160 | + public void testUrl() throws Exception { |
| 161 | + assertEquals("https://www.youtube.com/podcasts/popularepisodes", extractor().getUrl()); |
| 162 | + } |
| 163 | + |
| 164 | + @Override |
| 165 | + @Test |
| 166 | + public void testOriginalUrl() throws Exception { |
| 167 | + assertEquals("https://www.youtube.com/podcasts/popularepisodes", |
| 168 | + extractor().getOriginalUrl()); |
| 169 | + } |
| 170 | + |
| 171 | + @Override |
| 172 | + @Test |
| 173 | + public void testRelatedItems() throws Exception { |
| 174 | + defaultTestRelatedItems(extractor()); |
| 175 | + } |
| 176 | + |
| 177 | + @Override |
| 178 | + @Test |
| 179 | + public void testMoreRelatedItems() throws Exception { |
| 180 | + assertNoMoreItems(extractor()); |
| 181 | + } |
| 182 | + } |
| 183 | + |
| 184 | + public static class TrendingGamingVideos extends |
| 185 | + DefaultSimpleExtractorTest<YoutubeTrendingGamingVideosExtractor> |
| 186 | + implements BaseListExtractorTest, InitYoutubeTest { |
| 187 | + @Override |
| 188 | + protected YoutubeTrendingGamingVideosExtractor createExtractor() throws Exception { |
| 189 | + return (YoutubeTrendingGamingVideosExtractor) YouTube.getKioskList() |
| 190 | + .getExtractorById("trending_gaming", null); |
| 191 | + } |
| 192 | + |
| 193 | + @Override |
| 194 | + @Test |
| 195 | + public void testServiceId() { |
| 196 | + assertEquals(YouTube.getServiceId(), extractor().getServiceId()); |
| 197 | + } |
| 198 | + |
| 199 | + @Override |
| 200 | + @Test |
| 201 | + public void testName() throws Exception { |
| 202 | + // The name is the title of channel and not of the section |
| 203 | + assertEquals("Gaming", extractor().getName()); |
| 204 | + } |
| 205 | + |
| 206 | + @Override |
| 207 | + @Test |
| 208 | + public void testId() throws Exception { |
| 209 | + assertEquals("trending_gaming", extractor().getId()); |
| 210 | + } |
| 211 | + |
| 212 | + @Override |
| 213 | + @Test |
| 214 | + public void testUrl() throws Exception { |
| 215 | + assertEquals("https://www.youtube.com/gaming/trending", extractor().getUrl()); |
| 216 | + } |
| 217 | + |
| 218 | + @Override |
| 219 | + @Test |
| 220 | + public void testOriginalUrl() throws Exception { |
| 221 | + assertEquals("https://www.youtube.com/gaming/trending", extractor().getOriginalUrl()); |
| 222 | + } |
| 223 | + |
| 224 | + @Override |
| 225 | + @Test |
| 226 | + public void testRelatedItems() throws Exception { |
| 227 | + defaultTestRelatedItems(extractor()); |
| 228 | + } |
| 229 | + |
| 230 | + @Override |
| 231 | + @Test |
| 232 | + public void testMoreRelatedItems() throws Exception { |
| 233 | + assertNoMoreItems(extractor()); |
| 234 | + } |
| 235 | + } |
| 236 | + |
| 237 | + public static class TrendingMoviesAndShowsTrailers extends |
| 238 | + DefaultSimpleExtractorTest<YoutubeTrendingMoviesAndShowsTrailersExtractor> |
| 239 | + implements BaseListExtractorTest, InitYoutubeTest { |
| 240 | + @Override |
| 241 | + protected YoutubeTrendingMoviesAndShowsTrailersExtractor createExtractor() throws Exception { |
| 242 | + return (YoutubeTrendingMoviesAndShowsTrailersExtractor) YouTube.getKioskList() |
| 243 | + .getExtractorById("trending_movies_and_shows", null); |
| 244 | + } |
| 245 | + |
| 246 | + @Override |
| 247 | + @Test |
| 248 | + public void testServiceId() { |
| 249 | + assertEquals(YouTube.getServiceId(), extractor().getServiceId()); |
| 250 | + } |
| 251 | + |
| 252 | + @Override |
| 253 | + @Test |
| 254 | + public void testName() throws Exception { |
| 255 | + // The title is hardcoded in the extractor, as InnerTube responses don't provide it |
| 256 | + // (handled client-side) |
| 257 | + assertEquals("Trending Movie Trailers", extractor().getName()); |
| 258 | + } |
| 259 | + |
| 260 | + @Override |
| 261 | + @Test |
| 262 | + public void testId() throws Exception { |
| 263 | + assertEquals("trending_movies_and_shows", extractor().getId()); |
| 264 | + } |
| 265 | + |
| 266 | + @Override |
| 267 | + @Test |
| 268 | + public void testUrl() throws Exception { |
| 269 | + assertEquals("https://charts.youtube.com/charts/TrendingTrailers", |
| 270 | + extractor().getUrl()); |
| 271 | + } |
| 272 | + |
| 273 | + @Override |
| 274 | + @Test |
| 275 | + public void testOriginalUrl() throws Exception { |
| 276 | + assertEquals("https://charts.youtube.com/charts/TrendingTrailers", |
| 277 | + extractor().getOriginalUrl()); |
| 278 | + } |
| 279 | + |
| 280 | + @Override |
| 281 | + @Test |
| 282 | + public void testRelatedItems() throws Exception { |
| 283 | + defaultTestRelatedItems(extractor()); |
| 284 | + } |
| 285 | + |
| 286 | + @Override |
| 287 | + @Test |
| 288 | + public void testMoreRelatedItems() throws Exception { |
| 289 | + assertNoMoreItems(extractor()); |
| 290 | + } |
| 291 | + } |
| 292 | + |
| 293 | + public static class TrendingMusic extends |
| 294 | + DefaultSimpleExtractorTest<YoutubeTrendingMusicExtractor> |
| 295 | + implements BaseListExtractorTest, InitYoutubeTest { |
| 296 | + @Override |
| 297 | + protected YoutubeTrendingMusicExtractor createExtractor() throws Exception { |
| 298 | + return (YoutubeTrendingMusicExtractor) YouTube.getKioskList() |
| 299 | + .getExtractorById("trending_music", null); |
| 300 | + } |
| 301 | + |
| 302 | + @Override |
| 303 | + @Test |
| 304 | + public void testServiceId() { |
| 305 | + assertEquals(YouTube.getServiceId(), extractor().getServiceId()); |
| 306 | + } |
| 307 | + |
| 308 | + @Override |
| 309 | + @Test |
| 310 | + public void testName() throws Exception { |
| 311 | + // The title is hardcoded in the extractor, as InnerTube responses don't provide it |
| 312 | + // (handled client-side) |
| 313 | + assertEquals("Trending Music Videos", extractor().getName()); |
| 314 | + } |
| 315 | + |
| 316 | + @Override |
| 317 | + @Test |
| 318 | + public void testId() throws Exception { |
| 319 | + assertEquals("trending_music", extractor().getId()); |
| 320 | + } |
| 321 | + |
| 322 | + @Override |
| 323 | + @Test |
| 324 | + public void testUrl() throws Exception { |
| 325 | + assertEquals("https://charts.youtube.com/charts/TrendingVideos/RightNow", |
| 326 | + extractor().getUrl()); |
| 327 | + } |
| 328 | + |
| 329 | + @Override |
| 330 | + @Test |
| 331 | + public void testOriginalUrl() throws Exception { |
| 332 | + assertEquals("https://charts.youtube.com/charts/TrendingVideos/RightNow", |
| 333 | + extractor().getOriginalUrl()); |
| 334 | + } |
| 335 | + |
| 336 | + @Override |
| 337 | + @Test |
| 338 | + public void testRelatedItems() throws Exception { |
| 339 | + defaultTestRelatedItems(extractor()); |
| 340 | + } |
| 341 | + |
| 342 | + @Override |
| 343 | + @Test |
| 344 | + public void testMoreRelatedItems() throws Exception { |
| 345 | + assertNoMoreItems(extractor()); |
| 346 | + } |
| 347 | + } |
66 | 348 | } |
0 commit comments