mirror of
				https://github.com/TeamPiped/Piped.git
				synced 2024-08-14 23:57:27 +00:00 
			
		
		
		
	Merge pull request #2413 from Bnyro/import-multiple-playlists
Allow importing muliple playlists at once
This commit is contained in:
		
						commit
						f0fdeb18e3
					
				
					 1 changed files with 15 additions and 3 deletions
				
			
		| 
						 | 
					@ -10,7 +10,14 @@
 | 
				
			||||||
                class="btn"
 | 
					                class="btn"
 | 
				
			||||||
                @click="exportPlaylists"
 | 
					                @click="exportPlaylists"
 | 
				
			||||||
            />
 | 
					            />
 | 
				
			||||||
            <input id="fileSelector" ref="fileSelector" type="file" class="display-none" @change="importPlaylists" />
 | 
					            <input
 | 
				
			||||||
 | 
					                id="fileSelector"
 | 
				
			||||||
 | 
					                ref="fileSelector"
 | 
				
			||||||
 | 
					                type="file"
 | 
				
			||||||
 | 
					                class="display-none"
 | 
				
			||||||
 | 
					                @change="importPlaylists"
 | 
				
			||||||
 | 
					                multiple="multiple"
 | 
				
			||||||
 | 
					            />
 | 
				
			||||||
            <label for="fileSelector" v-t="'actions.import_from_json'" class="btn ml-2" />
 | 
					            <label for="fileSelector" v-t="'actions.import_from_json'" class="btn ml-2" />
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
| 
						 | 
					@ -180,7 +187,13 @@ export default {
 | 
				
			||||||
            return playlistJson;
 | 
					            return playlistJson;
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        async importPlaylists() {
 | 
					        async importPlaylists() {
 | 
				
			||||||
            const file = this.$refs.fileSelector.files[0];
 | 
					            const files = this.$refs.fileSelector.files;
 | 
				
			||||||
 | 
					            for (let file of files) {
 | 
				
			||||||
 | 
					                await this.importPlaylistFile(file);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            window.location.reload();
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        async importPlaylistFile(file) {
 | 
				
			||||||
            let text = await file.text();
 | 
					            let text = await file.text();
 | 
				
			||||||
            let tasks = [];
 | 
					            let tasks = [];
 | 
				
			||||||
            // list of playlists exported from Piped
 | 
					            // list of playlists exported from Piped
 | 
				
			||||||
| 
						 | 
					@ -209,7 +222,6 @@ export default {
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            await Promise.all(tasks);
 | 
					            await Promise.all(tasks);
 | 
				
			||||||
            window.location.reload();
 | 
					 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        async createPlaylistWithVideos(playlist) {
 | 
					        async createPlaylistWithVideos(playlist) {
 | 
				
			||||||
            let newPlaylist = await this.createPlaylist(playlist.name);
 | 
					            let newPlaylist = await this.createPlaylist(playlist.name);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue