mirror of
				https://github.com/TeamPiped/Piped.git
				synced 2024-08-14 23:57:27 +00:00 
			
		
		
		
	
							parent
							
								
									f8e4c70ea0
								
							
						
					
					
						commit
						9539d51126
					
				
					 6 changed files with 27 additions and 41 deletions
				
			
		| 
						 | 
				
			
			@ -148,6 +148,7 @@ export default {
 | 
			
		|||
                        this.contentItems = this.channel.relatedStreams;
 | 
			
		||||
                        this.fetchSubscribedStatus();
 | 
			
		||||
                        this.updateWatched(this.channel.relatedStreams);
 | 
			
		||||
                        this.fetchDeArrowContent(this.channel.relatedStreams);
 | 
			
		||||
                        this.tabs.push({
 | 
			
		||||
                            translatedName: this.$t("video.videos"),
 | 
			
		||||
                        });
 | 
			
		||||
| 
						 | 
				
			
			@ -186,6 +187,7 @@ export default {
 | 
			
		|||
                this.loading = false;
 | 
			
		||||
                this.updateWatched(json.relatedStreams);
 | 
			
		||||
                json.relatedStreams.map(stream => this.contentItems.push(stream));
 | 
			
		||||
                this.fetchDeArrowContent(this.contentItems);
 | 
			
		||||
            });
 | 
			
		||||
        },
 | 
			
		||||
        fetchChannelTabNextPage() {
 | 
			
		||||
| 
						 | 
				
			
			@ -196,6 +198,7 @@ export default {
 | 
			
		|||
                this.tabs[this.selectedTab].tabNextPage = json.nextpage;
 | 
			
		||||
                this.loading = false;
 | 
			
		||||
                json.content.map(item => this.contentItems.push(item));
 | 
			
		||||
                this.fetchDeArrowContent(this.contentItems);
 | 
			
		||||
                this.tabs[this.selectedTab].content = this.contentItems;
 | 
			
		||||
            });
 | 
			
		||||
        },
 | 
			
		||||
| 
						 | 
				
			
			@ -258,6 +261,7 @@ export default {
 | 
			
		|||
                data: this.tabs[index].data,
 | 
			
		||||
            }).then(tab => {
 | 
			
		||||
                this.contentItems = this.tabs[index].content = tab.content;
 | 
			
		||||
                this.fetchDeArrowContent(this.contentItems);
 | 
			
		||||
                this.tabs[this.selectedTab].tabNextPage = tab.nextpage;
 | 
			
		||||
            });
 | 
			
		||||
        },
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -138,18 +138,8 @@ export default {
 | 
			
		|||
        loadMoreVideos() {
 | 
			
		||||
            this.currentVideoCount = Math.min(this.currentVideoCount + this.videoStep, this.videosStore.length);
 | 
			
		||||
            if (this.videos.length != this.videosStore.length) {
 | 
			
		||||
                const videoIds = this.videosStore
 | 
			
		||||
                    .slice(this.videos.length, this.currentVideoCount)
 | 
			
		||||
                    .map(video => video.url.substr(-11))
 | 
			
		||||
                    .sort();
 | 
			
		||||
                if (this.getPreferenceBoolean("dearrow", false))
 | 
			
		||||
                    this.fetchDeArrowContent(videoIds).then(json => {
 | 
			
		||||
                        Object.keys(json).forEach(key => {
 | 
			
		||||
                            const video = this.videosStore.find(video => video.url.substr(-11) == key);
 | 
			
		||||
                            video.dearrow = json[key];
 | 
			
		||||
                        });
 | 
			
		||||
                    });
 | 
			
		||||
                this.videos = this.videosStore.slice(0, this.currentVideoCount);
 | 
			
		||||
                this.fetchDeArrowContent(this.videos);
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        handleScroll() {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -116,6 +116,7 @@ export default {
 | 
			
		|||
                .then(() => {
 | 
			
		||||
                    this.updateTitle();
 | 
			
		||||
                    this.updateWatched(this.playlist.relatedStreams);
 | 
			
		||||
                    this.fetchDeArrowContent(this.playlist.relatedStreams);
 | 
			
		||||
                });
 | 
			
		||||
        },
 | 
			
		||||
        async updateTitle() {
 | 
			
		||||
| 
						 | 
				
			
			@ -132,6 +133,7 @@ export default {
 | 
			
		|||
                    this.playlist.nextpage = json.nextpage;
 | 
			
		||||
                    this.loading = false;
 | 
			
		||||
                    json.relatedStreams.map(stream => this.playlist.relatedStreams.push(stream));
 | 
			
		||||
                    this.fetchDeArrowContent(this.playlist.relatedStreams);
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,13 +29,7 @@ export default {
 | 
			
		|||
        this.fetchTrending(region).then(videos => {
 | 
			
		||||
            this.videos = videos;
 | 
			
		||||
            this.updateWatched(this.videos);
 | 
			
		||||
            const videoIds = this.videos.map(video => video.url.substr(-11)).sort();
 | 
			
		||||
            this.fetchDeArrowContent(videoIds).then(json => {
 | 
			
		||||
                Object.keys(json).forEach(key => {
 | 
			
		||||
                    const video = this.videos.find(video => video.url.substr(-11) == key);
 | 
			
		||||
                    video.dearrow = json[key];
 | 
			
		||||
                });
 | 
			
		||||
            });
 | 
			
		||||
            this.fetchDeArrowContent(this.videos);
 | 
			
		||||
        });
 | 
			
		||||
    },
 | 
			
		||||
    activated() {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -454,16 +454,7 @@ export default {
 | 
			
		|||
                        this.video.description = this.rewriteDescription(xmlDoc.querySelector("body").innerHTML);
 | 
			
		||||
                        this.updateWatched(this.video.relatedStreams);
 | 
			
		||||
 | 
			
		||||
                        const videoIds = this.video.relatedStreams
 | 
			
		||||
                            .filter(obj => obj.type === "stream")
 | 
			
		||||
                            .map(video => video.url.substr(-11))
 | 
			
		||||
                            .sort();
 | 
			
		||||
                        this.fetchDeArrowContent(videoIds).then(json => {
 | 
			
		||||
                            Object.keys(json).forEach(key => {
 | 
			
		||||
                                const video = this.video.relatedStreams.find(video => video.url.substr(-11) == key);
 | 
			
		||||
                                video.dearrow = json[key];
 | 
			
		||||
                            });
 | 
			
		||||
                        });
 | 
			
		||||
                        this.fetchDeArrowContent(this.video.relatedStreams);
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
        },
 | 
			
		||||
| 
						 | 
				
			
			@ -485,16 +476,7 @@ export default {
 | 
			
		|||
                    }
 | 
			
		||||
                });
 | 
			
		||||
                await this.fetchPlaylistPages().then(() => {
 | 
			
		||||
                    const videoIds = this.playlist.relatedStreams
 | 
			
		||||
                        .filter(obj => obj.type === "stream")
 | 
			
		||||
                        .map(video => video.url.substr(-11))
 | 
			
		||||
                        .sort();
 | 
			
		||||
                    this.fetchDeArrowContent(videoIds).then(json => {
 | 
			
		||||
                        Object.keys(json).forEach(key => {
 | 
			
		||||
                            const video = this.playlist.relatedStreams.find(video => video.url.substr(-11) == key);
 | 
			
		||||
                            video.dearrow = json[key];
 | 
			
		||||
                        });
 | 
			
		||||
                    });
 | 
			
		||||
                    this.fetchDeArrowContent(this.playlist.relatedStreams);
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										20
									
								
								src/main.js
									
										
									
									
									
								
							
							
						
						
									
										20
									
								
								src/main.js
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -542,10 +542,24 @@ const mixin = {
 | 
			
		|||
                    return undefined;
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        fetchDeArrowContent(videoIds) {
 | 
			
		||||
            if (!this.getPreferenceBoolean("dearrow", false)) return new Promise(resolve => resolve({}));
 | 
			
		||||
            return this.fetchJson(this.apiUrl() + "/dearrow", {
 | 
			
		||||
        fetchDeArrowContent(content) {
 | 
			
		||||
            if (!this.getPreferenceBoolean("dearrow", false)) return;
 | 
			
		||||
 | 
			
		||||
            const videoIds = content
 | 
			
		||||
                .filter(item => item.type === "stream")
 | 
			
		||||
                .filter(item => item.dearrow === undefined)
 | 
			
		||||
                .map(item => item.url.substr(-11))
 | 
			
		||||
                .sort();
 | 
			
		||||
 | 
			
		||||
            if (videoIds.length === 0) return;
 | 
			
		||||
 | 
			
		||||
            this.fetchJson(this.apiUrl() + "/dearrow", {
 | 
			
		||||
                videoIds: videoIds.join(","),
 | 
			
		||||
            }).then(json => {
 | 
			
		||||
                Object.keys(json).forEach(videoId => {
 | 
			
		||||
                    const item = content.find(item => item.url.endsWith(videoId));
 | 
			
		||||
                    if (item) item.dearrow = json[videoId];
 | 
			
		||||
                });
 | 
			
		||||
            });
 | 
			
		||||
        },
 | 
			
		||||
    },
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue