MCPcopy Index your code
hub / github.com/watsonbox/exportify / export

Method export

src/components/PlaylistsExporter.tsx:27–63  ·  view source on GitHub ↗
(accessToken: string, playlistsData: PlaylistsData, searchQuery: string, config: any)

Source from the content-addressed store, hash-verified

25 }
26
27 async export(accessToken: string, playlistsData: PlaylistsData, searchQuery: string, config: any) {
28 let playlistFileNames = new Set<string>()
29 let playlistCsvExports = new Array<string>()
30
31 const playlists = searchQuery === "" ? await playlistsData.all() : await playlistsData.search(searchQuery)
32
33 let doneCount = 0
34
35 for (const playlist of playlists) {
36 this.props.onPlaylistExportStarted(playlist.name, doneCount)
37
38 let exporter = new PlaylistExporter(accessToken, playlist, config)
39 let csvData = await exporter.csvData()
40 let fileName = exporter.fileName(false)
41
42 for (let i = 1; playlistFileNames.has(fileName + exporter.fileExtension()); i++) {
43 fileName = exporter.fileName(false) + ` (${i})`
44 }
45
46 playlistFileNames.add(fileName + exporter.fileExtension())
47 playlistCsvExports.push(csvData)
48
49 doneCount++
50 }
51
52 this.props.onPlaylistsExportDone()
53
54 var zip = new JSZip()
55
56 Array.from(playlistFileNames).forEach(function (fileName, i) {
57 zip.file(fileName, playlistCsvExports[i])
58 })
59
60 zip.generateAsync({ type: "blob" }).then(function (content) {
61 saveAs(content, "spotify_playlists.zip");
62 })
63 }
64
65 exportPlaylists = () => {
66 this.setState(

Callers 1

PlaylistsExporterClass · 0.95

Calls 5

csvDataMethod · 0.95
fileNameMethod · 0.95
fileExtensionMethod · 0.95
allMethod · 0.80
searchMethod · 0.80

Tested by

no test coverage detected