playlists.js 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476
  1. import async from "async";
  2. import CoreClass from "../core";
  3. let PlaylistsModule;
  4. let StationsModule;
  5. let SongsModule;
  6. let CacheModule;
  7. let DBModule;
  8. let UtilsModule;
  9. let MediaModule;
  10. let WSModule;
  11. class _PlaylistsModule extends CoreClass {
  12. // eslint-disable-next-line require-jsdoc
  13. constructor() {
  14. super("playlists");
  15. PlaylistsModule = this;
  16. }
  17. /**
  18. * Initialises the playlists module
  19. *
  20. * @returns {Promise} - returns promise (reject, resolve)
  21. */
  22. async initialize() {
  23. this.setStage(1);
  24. StationsModule = this.moduleManager.modules.stations;
  25. CacheModule = this.moduleManager.modules.cache;
  26. DBModule = this.moduleManager.modules.db;
  27. UtilsModule = this.moduleManager.modules.utils;
  28. SongsModule = this.moduleManager.modules.songs;
  29. MediaModule = this.moduleManager.modules.media;
  30. WSModule = this.moduleManager.modules.ws;
  31. this.playlistModel = await DBModule.runJob("GET_MODEL", { modelName: "playlist" });
  32. this.playlistSchemaCache = await CacheModule.runJob("GET_SCHEMA", { schemaName: "playlist" });
  33. CacheModule.runJob("SUB", {
  34. channel: "playlist.updated",
  35. cb: async data => {
  36. PlaylistsModule.playlistModel.findOne(
  37. { _id: data.playlistId },
  38. ["_id", "displayName", "type", "privacy", "songs", "createdBy", "createdAt", "createdFor"],
  39. (err, playlist) => {
  40. const newPlaylist = {
  41. ...playlist._doc,
  42. songsCount: playlist.songs.length,
  43. songsLength: playlist.songs.reduce(
  44. (previous, current) => ({
  45. duration: previous.duration + current.duration
  46. }),
  47. { duration: 0 }
  48. ).duration
  49. };
  50. delete newPlaylist.songs;
  51. WSModule.runJob("EMIT_TO_ROOM", {
  52. room: "admin.playlists",
  53. args: ["event:admin.playlist.updated", { data: { playlist: newPlaylist } }]
  54. });
  55. }
  56. );
  57. }
  58. });
  59. this.setStage(2);
  60. return new Promise((resolve, reject) => {
  61. async.waterfall(
  62. [
  63. next => {
  64. this.setStage(3);
  65. CacheModule.runJob("HGETALL", { table: "playlists" })
  66. .then(playlists => {
  67. next(null, playlists);
  68. })
  69. .catch(next);
  70. },
  71. (playlists, next) => {
  72. this.setStage(4);
  73. if (!playlists) return next();
  74. const playlistIds = Object.keys(playlists);
  75. return async.each(
  76. playlistIds,
  77. (playlistId, next) => {
  78. PlaylistsModule.playlistModel.findOne({ _id: playlistId }, (err, playlist) => {
  79. if (err) next(err);
  80. else if (!playlist) {
  81. CacheModule.runJob("HDEL", {
  82. table: "playlists",
  83. key: playlistId
  84. })
  85. .then(() => next())
  86. .catch(next);
  87. } else next();
  88. });
  89. },
  90. next
  91. );
  92. },
  93. next => {
  94. this.setStage(5);
  95. PlaylistsModule.playlistModel.find({}, next);
  96. },
  97. (playlists, next) => {
  98. this.setStage(6);
  99. async.each(
  100. playlists,
  101. (playlist, cb) => {
  102. CacheModule.runJob("HSET", {
  103. table: "playlists",
  104. key: playlist._id,
  105. value: PlaylistsModule.playlistSchemaCache(playlist)
  106. })
  107. .then(() => cb())
  108. .catch(next);
  109. },
  110. next
  111. );
  112. }
  113. ],
  114. async err => {
  115. if (err) {
  116. const formattedErr = await UtilsModule.runJob("GET_ERROR", {
  117. error: err
  118. });
  119. reject(new Error(formattedErr));
  120. } else {
  121. resolve();
  122. }
  123. }
  124. );
  125. });
  126. }
  127. /**
  128. * Returns a list of playlists that include a specific song
  129. *
  130. * @param {object} payload - object that contains the payload
  131. * @param {string} payload.songId - the song id
  132. * @param {string} payload.includeSongs - include the songs
  133. * @returns {Promise} - returns promise (reject, resolve)
  134. */
  135. GET_PLAYLISTS_WITH_SONG(payload) {
  136. return new Promise((resolve, reject) => {
  137. const includeObject = payload.includeSongs ? null : { songs: false };
  138. PlaylistsModule.playlistModel.find({ "songs._id": payload.songId }, includeObject, (err, playlists) => {
  139. if (err) reject(err);
  140. else resolve({ playlists });
  141. });
  142. });
  143. }
  144. // /**
  145. // * Returns a list of youtube ids in all user playlists of the specified user
  146. // *
  147. // * @param {object} payload - object that contains the payload
  148. // * @param {string} payload.userId - the user id
  149. // * @returns {Promise} - returns promise (reject, resolve)
  150. // */
  151. // GET_SONG_YOUTUBE_IDS_FROM_PLAYLISTS(payload) {
  152. // return new Promise((resolve, reject) => {
  153. // PlaylistsModule.playlistModel.find({ createdBy: payload.userId }, (err, playlists) => {
  154. // const youtubeIds = new Set();
  155. // if (err) reject(err);
  156. // else {
  157. // playlists.forEach(playlist => {
  158. // playlist.songs.forEach(song => {
  159. // youtubeIds.add(song.youtubeId);
  160. // });
  161. // });
  162. // console.log(Array.from(youtubeIds));
  163. // resolve({ youtubeIds: Array.from(youtubeIds) });
  164. // }
  165. // });
  166. // });
  167. // }
  168. /**
  169. * Creates a playlist owned by a user
  170. *
  171. * @param {object} payload - object that contains the payload
  172. * @param {string} payload.userId - the id of the user to create the playlist for
  173. * @param {string} payload.displayName - the display name of the playlist
  174. * @param {string} payload.type - the type of the playlist
  175. * @returns {Promise} - returns promise (reject, resolve)
  176. */
  177. CREATE_USER_PLAYLIST(payload) {
  178. return new Promise((resolve, reject) => {
  179. PlaylistsModule.playlistModel.create(
  180. {
  181. displayName: payload.displayName,
  182. songs: [],
  183. createdBy: payload.userId,
  184. createdAt: Date.now(),
  185. createdFor: null,
  186. type: payload.type
  187. },
  188. (err, playlist) => {
  189. if (err) return reject(new Error(err));
  190. return resolve(playlist._id);
  191. }
  192. );
  193. });
  194. }
  195. /**
  196. * Creates a playlist that contains all songs of a specific genre
  197. *
  198. * @param {object} payload - object that contains the payload
  199. * @param {string} payload.genre - the genre
  200. * @returns {Promise} - returns promise (reject, resolve)
  201. */
  202. CREATE_GENRE_PLAYLIST(payload) {
  203. return new Promise((resolve, reject) => {
  204. PlaylistsModule.runJob("GET_GENRE_PLAYLIST", { genre: payload.genre.toLowerCase() }, this)
  205. .then(() => {
  206. reject(new Error("Playlist already exists"));
  207. })
  208. .catch(err => {
  209. if (err.message === "Playlist not found") {
  210. PlaylistsModule.playlistModel.create(
  211. {
  212. displayName: `Genre - ${payload.genre}`,
  213. songs: [],
  214. createdBy: "Musare",
  215. createdFor: `${payload.genre.toLowerCase()}`,
  216. createdAt: Date.now(),
  217. type: "genre"
  218. },
  219. (err, playlist) => {
  220. if (err) return reject(new Error(err));
  221. return resolve(playlist._id);
  222. }
  223. );
  224. } else reject(new Error(err));
  225. });
  226. });
  227. }
  228. /**
  229. * Gets all genre playlists
  230. *
  231. * @param {object} payload - object that contains the payload
  232. * @param {string} payload.includeSongs - include the songs
  233. * @returns {Promise} - returns promise (reject, resolve)
  234. */
  235. GET_ALL_GENRE_PLAYLISTS(payload) {
  236. return new Promise((resolve, reject) => {
  237. const includeObject = payload.includeSongs ? null : { songs: false };
  238. PlaylistsModule.playlistModel.find({ type: "genre" }, includeObject, (err, playlists) => {
  239. if (err) reject(new Error(err));
  240. else resolve({ playlists });
  241. });
  242. });
  243. }
  244. /**
  245. * Gets all station playlists
  246. *
  247. * @param {object} payload - object that contains the payload
  248. * @param {string} payload.includeSongs - include the songs
  249. * @returns {Promise} - returns promise (reject, resolve)
  250. */
  251. GET_ALL_STATION_PLAYLISTS(payload) {
  252. return new Promise((resolve, reject) => {
  253. const includeObject = payload.includeSongs ? null : { songs: false };
  254. PlaylistsModule.playlistModel.find({ type: "station" }, includeObject, (err, playlists) => {
  255. if (err) reject(new Error(err));
  256. else resolve({ playlists });
  257. });
  258. });
  259. }
  260. /**
  261. * Gets a genre playlist
  262. *
  263. * @param {object} payload - object that contains the payload
  264. * @param {string} payload.genre - the genre
  265. * @param {string} payload.includeSongs - include the songs
  266. * @returns {Promise} - returns promise (reject, resolve)
  267. */
  268. GET_GENRE_PLAYLIST(payload) {
  269. return new Promise((resolve, reject) => {
  270. const includeObject = payload.includeSongs ? null : { songs: false };
  271. PlaylistsModule.playlistModel.findOne(
  272. { type: "genre", createdFor: payload.genre },
  273. includeObject,
  274. (err, playlist) => {
  275. if (err) reject(new Error(err));
  276. else if (!playlist) reject(new Error("Playlist not found"));
  277. else resolve({ playlist });
  278. }
  279. );
  280. });
  281. }
  282. /**
  283. * Gets all missing genre playlists
  284. *
  285. * @returns {Promise} - returns promise (reject, resolve)
  286. */
  287. GET_MISSING_GENRE_PLAYLISTS() {
  288. return new Promise((resolve, reject) => {
  289. SongsModule.runJob("GET_ALL_GENRES", {}, this)
  290. .then(response => {
  291. const { genres } = response;
  292. const missingGenres = [];
  293. async.eachLimit(
  294. genres,
  295. 1,
  296. (genre, next) => {
  297. PlaylistsModule.runJob(
  298. "GET_GENRE_PLAYLIST",
  299. { genre: genre.toLowerCase(), includeSongs: false },
  300. this
  301. )
  302. .then(() => {
  303. next();
  304. })
  305. .catch(err => {
  306. if (err.message === "Playlist not found") {
  307. missingGenres.push(genre);
  308. next();
  309. } else next(err);
  310. });
  311. },
  312. err => {
  313. if (err) reject(err);
  314. else resolve({ genres: missingGenres });
  315. }
  316. );
  317. })
  318. .catch(err => {
  319. reject(err);
  320. });
  321. });
  322. }
  323. /**
  324. * Creates all missing genre playlists
  325. *
  326. * @returns {Promise} - returns promise (reject, resolve)
  327. */
  328. CREATE_MISSING_GENRE_PLAYLISTS() {
  329. return new Promise((resolve, reject) => {
  330. PlaylistsModule.runJob("GET_MISSING_GENRE_PLAYLISTS", {}, this)
  331. .then(response => {
  332. const { genres } = response;
  333. async.eachLimit(
  334. genres,
  335. 1,
  336. (genre, next) => {
  337. PlaylistsModule.runJob("CREATE_GENRE_PLAYLIST", { genre }, this)
  338. .then(() => {
  339. next();
  340. })
  341. .catch(err => {
  342. next(err);
  343. });
  344. },
  345. err => {
  346. if (err) reject(err);
  347. else resolve();
  348. }
  349. );
  350. })
  351. .catch(err => {
  352. reject(err);
  353. });
  354. });
  355. }
  356. /**
  357. * Gets a station playlist
  358. *
  359. * @param {object} payload - object that contains the payload
  360. * @param {string} payload.staationId - the station id
  361. * @param {string} payload.includeSongs - include the songs
  362. * @returns {Promise} - returns promise (reject, resolve)
  363. */
  364. GET_STATION_PLAYLIST(payload) {
  365. return new Promise((resolve, reject) => {
  366. const includeObject = payload.includeSongs ? null : { songs: false };
  367. PlaylistsModule.playlistModel.findOne(
  368. { type: "station", createdFor: payload.stationId },
  369. includeObject,
  370. (err, playlist) => {
  371. if (err) reject(new Error(err));
  372. else if (!playlist) reject(new Error("Playlist not found"));
  373. else resolve({ playlist });
  374. }
  375. );
  376. });
  377. }
  378. /**
  379. * Adds a song to a playlist
  380. *
  381. * @param {object} payload - object that contains the payload
  382. * @param {string} payload.playlistId - the playlist id
  383. * @param {string} payload.mediaSource - the media source
  384. * @returns {Promise} - returns promise (reject, resolve)
  385. */
  386. ADD_SONG_TO_PLAYLIST(payload) {
  387. return new Promise((resolve, reject) => {
  388. const { playlistId, mediaSource } = payload;
  389. async.waterfall(
  390. [
  391. next => {
  392. PlaylistsModule.runJob("GET_PLAYLIST", { playlistId }, this)
  393. .then(playlist => {
  394. next(null, playlist);
  395. })
  396. .catch(next);
  397. },
  398. (playlist, next) => {
  399. if (!playlist) return next("Playlist not found.");
  400. if (playlist.songs.find(song => song.mediaSource === mediaSource))
  401. return next("That song is already in the playlist.");
  402. return next();
  403. },
  404. next => {
  405. MediaModule.runJob("GET_MEDIA", { mediaSource }, this)
  406. .then(response => {
  407. const { song } = response;
  408. const { _id, title, artists, thumbnail, duration, verified } = song;
  409. next(null, {
  410. _id,
  411. mediaSource,
  412. title,
  413. artists,
  414. thumbnail,
  415. duration,
  416. verified
  417. });
  418. })
  419. .catch(next);
  420. },
  421. (newSong, next) => {
  422. PlaylistsModule.playlistModel.updateOne(
  423. { _id: playlistId },
  424. { $push: { songs: newSong } },
  425. { runValidators: true },
  426. err => {
  427. if (err) return next(err);
  428. return PlaylistsModule.runJob("UPDATE_PLAYLIST", { playlistId }, this)
  429. .then(playlist => next(null, playlist, newSong))
  430. .catch(next);
  431. }
  432. );
  433. },
  434. (playlist, newSong, next) => {
  435. StationsModule.runJob("GET_STATIONS_THAT_AUTOFILL_OR_BLACKLIST_PLAYLIST", { playlistId })
  436. .then(response => {
  437. async.each(
  438. response.stationIds,
  439. (stationId, next) => {
  440. PlaylistsModule.runJob("AUTOFILL_STATION_PLAYLIST", { stationId })
  441. .then()
  442. .catch();
  443. next();
  444. },
  445. err => {
  446. if (err) next(err);
  447. else next(null, playlist, newSong);
  448. }
  449. );
  450. })
  451. .catch(next);
  452. },
  453. (playlist, newSong, next) => {
  454. if (playlist.type === "user-liked" || playlist.type === "user-disliked") {
  455. MediaModule.runJob("RECALCULATE_RATINGS", {
  456. mediaSource: newSong.mediaSource
  457. })
  458. .then(ratings => next(null, playlist, newSong, ratings))
  459. .catch(next);
  460. } else {
  461. next(null, playlist, newSong, null);
  462. }
  463. }
  464. ],
  465. (err, playlist, song, ratings) => {
  466. if (err) reject(err);
  467. else resolve({ playlist, song, ratings });
  468. }
  469. );
  470. });
  471. }
  472. /**
  473. * Replaces a song in a playlist
  474. *
  475. * @param {object} payload - object that contains the payload
  476. * @param {string} payload.playlistId - the playlist id
  477. * @param {string} payload.newMediaSource - the new media source
  478. * @param {string} payload.oldMediaSource - the old media source
  479. * @returns {Promise} - returns promise (reject, resolve)
  480. */
  481. REPLACE_SONG_IN_PLAYLIST(payload) {
  482. return new Promise((resolve, reject) => {
  483. const { playlistId, newMediaSource, oldMediaSource } = payload;
  484. console.log("KRISISISIS", payload, newMediaSource, oldMediaSource);
  485. async.waterfall(
  486. [
  487. next => {
  488. PlaylistsModule.runJob("GET_PLAYLIST", { playlistId }, this)
  489. .then(playlist => {
  490. next(null, playlist);
  491. })
  492. .catch(next);
  493. },
  494. (playlist, next) => {
  495. if (!playlist) return next("Playlist not found.");
  496. if (playlist.songs.find(song => song.mediaSource === newMediaSource))
  497. return next("The new song is already in the playlist.");
  498. return next();
  499. },
  500. next => {
  501. MediaModule.runJob("GET_MEDIA", { mediaSource: newMediaSource }, this)
  502. .then(response => {
  503. const { song } = response;
  504. const { _id, title, artists, thumbnail, duration, verified } = song;
  505. next(null, {
  506. _id,
  507. mediaSource: newMediaSource,
  508. title,
  509. artists,
  510. thumbnail,
  511. duration,
  512. verified
  513. });
  514. })
  515. .catch(next);
  516. },
  517. (newSong, next) => {
  518. PlaylistsModule.playlistModel.updateOne(
  519. { _id: playlistId, "songs.mediaSource": oldMediaSource },
  520. { $set: { "songs.$": newSong } },
  521. { runValidators: true },
  522. err => {
  523. if (err) return next(err);
  524. return PlaylistsModule.runJob("UPDATE_PLAYLIST", { playlistId }, this)
  525. .then(playlist => next(null, playlist, newSong))
  526. .catch(next);
  527. }
  528. );
  529. },
  530. (playlist, newSong, next) => {
  531. StationsModule.runJob("GET_STATIONS_THAT_AUTOFILL_OR_BLACKLIST_PLAYLIST", { playlistId })
  532. .then(response => {
  533. async.each(
  534. response.stationIds,
  535. (stationId, next) => {
  536. PlaylistsModule.runJob("AUTOFILL_STATION_PLAYLIST", { stationId })
  537. .then()
  538. .catch();
  539. next();
  540. },
  541. err => {
  542. if (err) next(err);
  543. else next(null, playlist, newSong);
  544. }
  545. );
  546. })
  547. .catch(next);
  548. },
  549. (playlist, newSong, next) => {
  550. if (playlist.type === "user-liked" || playlist.type === "user-disliked") {
  551. MediaModule.runJob("RECALCULATE_RATINGS", {
  552. mediaSource: newSong.mediaSource
  553. })
  554. .then(ratings => next(null, playlist, newSong, ratings))
  555. .catch(next);
  556. } else {
  557. next(null, playlist, newSong, null);
  558. }
  559. },
  560. (playlist, newSong, newRatings, next) => {
  561. if (playlist.type === "user-liked" || playlist.type === "user-disliked") {
  562. MediaModule.runJob("RECALCULATE_RATINGS", {
  563. mediaSource: oldMediaSource
  564. })
  565. .then(ratings => next(null, playlist, newSong, newRatings, oldRatings))
  566. .catch(next);
  567. } else {
  568. next(null, playlist, newSong, null, null);
  569. }
  570. }
  571. ],
  572. (err, playlist, song, newRatings, oldRatings) => {
  573. if (err) reject(err);
  574. else resolve({ playlist, song, newRatings, oldRatings });
  575. }
  576. );
  577. });
  578. }
  579. /**
  580. * Remove from playlist
  581. *
  582. * @param {object} payload - object that contains the payload
  583. * @param {string} payload.playlistId - the playlist id
  584. * @param {string} payload.mediaSource - the media source
  585. * @returns {Promise} - returns a promise (resolve, reject)
  586. */
  587. REMOVE_FROM_PLAYLIST(payload) {
  588. return new Promise((resolve, reject) => {
  589. const { playlistId, mediaSource } = payload;
  590. async.waterfall(
  591. [
  592. next => {
  593. PlaylistsModule.runJob("GET_PLAYLIST", { playlistId }, this)
  594. .then(playlist => {
  595. next(null, playlist);
  596. })
  597. .catch(next);
  598. },
  599. (playlist, next) => {
  600. if (!playlist) return next("Playlist not found.");
  601. if (!playlist.songs.find(song => song.mediaSource === mediaSource))
  602. return next("That song is not currently in the playlist.");
  603. return PlaylistsModule.playlistModel.updateOne(
  604. { _id: playlistId },
  605. { $pull: { songs: { mediaSource } } },
  606. next
  607. );
  608. },
  609. (res, next) => {
  610. PlaylistsModule.runJob("UPDATE_PLAYLIST", { playlistId }, this)
  611. .then(playlist => next(null, playlist))
  612. .catch(next);
  613. },
  614. (playlist, next) => {
  615. StationsModule.runJob("GET_STATIONS_THAT_AUTOFILL_OR_BLACKLIST_PLAYLIST", { playlistId })
  616. .then(response => {
  617. async.each(
  618. response.stationIds,
  619. (stationId, next) => {
  620. PlaylistsModule.runJob("AUTOFILL_STATION_PLAYLIST", { stationId })
  621. .then()
  622. .catch();
  623. next();
  624. },
  625. err => {
  626. if (err) next(err);
  627. else next(null, playlist);
  628. }
  629. );
  630. })
  631. .catch(next);
  632. },
  633. (playlist, next) => {
  634. if (playlist.type === "user-liked" || playlist.type === "user-disliked") {
  635. MediaModule.runJob("RECALCULATE_RATINGS", { mediaSource })
  636. .then(ratings => next(null, playlist, ratings))
  637. .catch(next);
  638. } else next(null, playlist, null);
  639. },
  640. (playlist, ratings, next) =>
  641. CacheModule.runJob(
  642. "PUB",
  643. {
  644. channel: "playlist.updated",
  645. value: { playlistId }
  646. },
  647. this
  648. )
  649. .then(() => next(null, playlist, ratings))
  650. .catch(next)
  651. ],
  652. (err, playlist, ratings) => {
  653. if (err) reject(err);
  654. else resolve({ playlist, ratings });
  655. }
  656. );
  657. });
  658. }
  659. /**
  660. * Deletes a song from a playlist based on the media source
  661. *
  662. * @param {object} payload - object that contains the payload
  663. * @param {string} payload.playlistId - the playlist id
  664. * @param {string} payload.mediaSource - the media source
  665. * @returns {Promise} - returns promise (reject, resolve)
  666. */
  667. DELETE_SONG_FROM_PLAYLIST_BY_MEDIA_SOURCE_ID(payload) {
  668. return new Promise((resolve, reject) => {
  669. PlaylistsModule.playlistModel.updateOne(
  670. { _id: payload.playlistId },
  671. { $pull: { songs: { mediaSource: payload.mediaSource } } },
  672. err => {
  673. if (err) reject(new Error(err));
  674. else {
  675. PlaylistsModule.runJob("UPDATE_PLAYLIST", { playlistId: payload.playlistId }, this)
  676. .then(() => resolve())
  677. .catch(err => {
  678. reject(new Error(err));
  679. });
  680. }
  681. }
  682. );
  683. });
  684. }
  685. /**
  686. * Fills a genre playlist with songs
  687. *
  688. * @param {object} payload - object that contains the payload
  689. * @param {string} payload.genre - the genre
  690. * @param {string} payload.createPlaylist - create playlist if it doesn't exist, default false
  691. * @returns {Promise} - returns promise (reject, resolve)
  692. */
  693. AUTOFILL_GENRE_PLAYLIST(payload) {
  694. return new Promise((resolve, reject) => {
  695. async.waterfall(
  696. [
  697. next => {
  698. PlaylistsModule.runJob(
  699. "GET_GENRE_PLAYLIST",
  700. { genre: payload.genre.toLowerCase(), includeSongs: true },
  701. this
  702. )
  703. .then(response => {
  704. next(null, response.playlist._id);
  705. })
  706. .catch(err => {
  707. if (err.message === "Playlist not found") {
  708. if (payload.createPlaylist)
  709. PlaylistsModule.runJob("CREATE_GENRE_PLAYLIST", { genre: payload.genre }, this)
  710. .then(playlistId => {
  711. next(null, playlistId);
  712. })
  713. .catch(err => {
  714. next(err);
  715. });
  716. } else next(err);
  717. });
  718. },
  719. (playlistId, next) => {
  720. SongsModule.runJob("GET_ALL_SONGS_WITH_GENRE", { genre: payload.genre }, this)
  721. .then(response => {
  722. next(null, playlistId, response.songs);
  723. })
  724. .catch(err => {
  725. console.log(err);
  726. next(err);
  727. });
  728. },
  729. (playlistId, _songs, next) => {
  730. const songs = _songs.map(song => {
  731. const { _id, mediaSource, title, artists, thumbnail, duration, verified } = song;
  732. return {
  733. _id,
  734. mediaSource,
  735. title,
  736. artists,
  737. thumbnail,
  738. duration,
  739. verified
  740. };
  741. });
  742. PlaylistsModule.playlistModel.updateOne({ _id: playlistId }, { $set: { songs } }, err => {
  743. next(err, playlistId);
  744. });
  745. },
  746. (playlistId, next) => {
  747. PlaylistsModule.runJob("UPDATE_PLAYLIST", { playlistId }, this)
  748. .then(() => {
  749. next(null, playlistId);
  750. })
  751. .catch(next);
  752. },
  753. (playlistId, next) => {
  754. StationsModule.runJob("GET_STATIONS_THAT_AUTOFILL_OR_BLACKLIST_PLAYLIST", { playlistId }, this)
  755. .then(response => {
  756. async.eachLimit(
  757. response.stationIds,
  758. 1,
  759. (stationId, next) => {
  760. PlaylistsModule.runJob("AUTOFILL_STATION_PLAYLIST", { stationId }, this)
  761. .then(() => {
  762. next();
  763. })
  764. .catch(err => {
  765. next(err);
  766. });
  767. },
  768. err => {
  769. if (err) next(err);
  770. else next();
  771. }
  772. );
  773. })
  774. .catch(err => {
  775. next(err);
  776. });
  777. }
  778. ],
  779. err => {
  780. if (err && err !== true) return reject(new Error(err));
  781. return resolve({});
  782. }
  783. );
  784. });
  785. }
  786. /**
  787. * Gets orphaned genre playlists
  788. *
  789. * @returns {Promise} - returns promise (reject, resolve)
  790. */
  791. GET_ORPHANED_GENRE_PLAYLISTS() {
  792. return new Promise((resolve, reject) => {
  793. PlaylistsModule.playlistModel.find({ type: "genre" }, { songs: false }, (err, playlists) => {
  794. if (err) reject(new Error(err));
  795. else {
  796. const orphanedPlaylists = [];
  797. async.eachLimit(
  798. playlists,
  799. 1,
  800. (playlist, next) => {
  801. SongsModule.runJob("GET_ALL_SONGS_WITH_GENRE", { genre: playlist.createdFor }, this)
  802. .then(response => {
  803. if (response.songs.length === 0) {
  804. StationsModule.runJob(
  805. "GET_STATIONS_THAT_AUTOFILL_OR_BLACKLIST_PLAYLIST",
  806. { playlistId: playlist._id },
  807. this
  808. )
  809. .then(response => {
  810. if (response.stationIds.length === 0) orphanedPlaylists.push(playlist);
  811. next();
  812. })
  813. .catch(next);
  814. } else next();
  815. })
  816. .catch(next);
  817. },
  818. err => {
  819. if (err) reject(new Error(err));
  820. else resolve({ playlists: orphanedPlaylists });
  821. }
  822. );
  823. }
  824. });
  825. });
  826. }
  827. /**
  828. * Deletes all orphaned genre playlists
  829. *
  830. * @returns {Promise} - returns promise (reject, resolve)
  831. */
  832. DELETE_ORPHANED_GENRE_PLAYLISTS() {
  833. return new Promise((resolve, reject) => {
  834. PlaylistsModule.runJob("GET_ORPHANED_GENRE_PLAYLISTS", {}, this)
  835. .then(response => {
  836. async.eachLimit(
  837. response.playlists,
  838. 1,
  839. (playlist, next) => {
  840. this.publishProgress({ status: "update", message: `Deleting "${playlist._id}"` });
  841. PlaylistsModule.runJob("DELETE_PLAYLIST", { playlistId: playlist._id }, this)
  842. .then(() => {
  843. this.log("INFO", "Deleting orphaned genre playlist");
  844. next();
  845. })
  846. .catch(err => {
  847. next(err);
  848. });
  849. },
  850. err => {
  851. if (err) reject(new Error(err));
  852. else resolve({});
  853. }
  854. );
  855. })
  856. .catch(err => {
  857. reject(new Error(err));
  858. });
  859. });
  860. }
  861. /**
  862. * Gets a orphaned station playlists
  863. *
  864. * @returns {Promise} - returns promise (reject, resolve)
  865. */
  866. GET_ORPHANED_STATION_PLAYLISTS() {
  867. return new Promise((resolve, reject) => {
  868. PlaylistsModule.playlistModel.find({ type: "station" }, { songs: false }, (err, playlists) => {
  869. if (err) reject(new Error(err));
  870. else {
  871. const orphanedPlaylists = [];
  872. async.eachLimit(
  873. playlists,
  874. 1,
  875. (playlist, next) => {
  876. StationsModule.runJob("GET_STATION", { stationId: playlist.createdFor }, this)
  877. .then(station => {
  878. if (station.playlist !== playlist._id.toString()) {
  879. orphanedPlaylists.push(playlist);
  880. }
  881. next();
  882. })
  883. .catch(err => {
  884. if (err.message === "Station not found") {
  885. orphanedPlaylists.push(playlist);
  886. next();
  887. } else next(err);
  888. });
  889. },
  890. err => {
  891. if (err) reject(new Error(err));
  892. else resolve({ playlists: orphanedPlaylists });
  893. }
  894. );
  895. }
  896. });
  897. });
  898. }
  899. /**
  900. * Deletes all orphaned station playlists
  901. *
  902. * @returns {Promise} - returns promise (reject, resolve)
  903. */
  904. DELETE_ORPHANED_STATION_PLAYLISTS() {
  905. return new Promise((resolve, reject) => {
  906. PlaylistsModule.runJob("GET_ORPHANED_STATION_PLAYLISTS", {}, this)
  907. .then(response => {
  908. async.eachLimit(
  909. response.playlists,
  910. 1,
  911. (playlist, next) => {
  912. this.publishProgress({ status: "update", message: `Deleting "${playlist._id}"` });
  913. PlaylistsModule.runJob("DELETE_PLAYLIST", { playlistId: playlist._id }, this)
  914. .then(() => {
  915. this.log("INFO", "Deleting orphaned station playlist");
  916. next();
  917. })
  918. .catch(err => {
  919. next(err);
  920. });
  921. },
  922. err => {
  923. if (err) reject(new Error(err));
  924. else resolve({});
  925. }
  926. );
  927. })
  928. .catch(err => {
  929. reject(new Error(err));
  930. });
  931. });
  932. }
  933. /**
  934. * Fills a station playlist with songs
  935. *
  936. * @param {object} payload - object that contains the payload
  937. * @param {string} payload.stationId - the station id
  938. * @returns {Promise} - returns promise (reject, resolve)
  939. */
  940. AUTOFILL_STATION_PLAYLIST(payload) {
  941. return new Promise((resolve, reject) => {
  942. let originalPlaylist = null;
  943. async.waterfall(
  944. [
  945. next => {
  946. if (!payload.stationId) next("Please specify a station id");
  947. else next();
  948. },
  949. next => {
  950. StationsModule.runJob("GET_STATION", { stationId: payload.stationId }, this)
  951. .then(station => {
  952. next(null, station);
  953. })
  954. .catch(next);
  955. },
  956. (station, next) => {
  957. PlaylistsModule.runJob("GET_PLAYLIST", { playlistId: station.playlist }, this)
  958. .then(playlist => {
  959. originalPlaylist = playlist;
  960. next(null, station);
  961. })
  962. .catch(err => {
  963. next(err);
  964. });
  965. },
  966. (station, next) => {
  967. const playlists = [];
  968. async.eachLimit(
  969. station.autofill.playlists,
  970. 1,
  971. (playlistId, next) => {
  972. PlaylistsModule.runJob("GET_PLAYLIST", { playlistId }, this)
  973. .then(playlist => {
  974. playlists.push(playlist);
  975. next();
  976. })
  977. .catch(next);
  978. },
  979. err => {
  980. next(err, station, playlists);
  981. }
  982. );
  983. },
  984. (station, playlists, next) => {
  985. const blacklist = [];
  986. async.eachLimit(
  987. station.blacklist,
  988. 1,
  989. (playlistId, next) => {
  990. PlaylistsModule.runJob("GET_PLAYLIST", { playlistId }, this)
  991. .then(playlist => {
  992. blacklist.push(playlist);
  993. next();
  994. })
  995. .catch(next);
  996. },
  997. err => {
  998. next(err, station, playlists, blacklist);
  999. }
  1000. );
  1001. },
  1002. (station, playlists, blacklist, next) => {
  1003. const blacklistedSongs = blacklist
  1004. .flatMap(blacklistedPlaylist => blacklistedPlaylist.songs)
  1005. .reduce(
  1006. (items, item) =>
  1007. items.find(x => x.mediaSource === item.mediaSource) ? [...items] : [...items, item],
  1008. []
  1009. );
  1010. const includedSongs = playlists
  1011. .flatMap(playlist => playlist.songs)
  1012. .reduce(
  1013. (songs, song) =>
  1014. songs.find(x => x.mediaSource === song.mediaSource) ? [...songs] : [...songs, song],
  1015. []
  1016. )
  1017. .filter(song => !blacklistedSongs.find(x => x.mediaSource === song.mediaSource));
  1018. next(null, station, includedSongs);
  1019. },
  1020. (station, includedSongs, next) => {
  1021. PlaylistsModule.playlistModel.updateOne(
  1022. { _id: station.playlist },
  1023. { $set: { songs: includedSongs } },
  1024. err => {
  1025. next(err, includedSongs);
  1026. }
  1027. );
  1028. },
  1029. (includedSongs, next) => {
  1030. PlaylistsModule.runJob("UPDATE_PLAYLIST", { playlistId: originalPlaylist._id }, this)
  1031. .then(() => {
  1032. next(null, includedSongs);
  1033. })
  1034. .catch(next);
  1035. },
  1036. (includedSongs, next) => {
  1037. if (originalPlaylist.songs.length === 0 && includedSongs.length > 0)
  1038. StationsModule.runJob("SKIP_STATION", {
  1039. stationId: payload.stationId,
  1040. natural: false,
  1041. skipReason: "other"
  1042. });
  1043. next();
  1044. }
  1045. ],
  1046. err => {
  1047. if (err && err !== true) return reject(new Error(err));
  1048. return resolve({});
  1049. }
  1050. );
  1051. });
  1052. }
  1053. /**
  1054. * Gets a playlist by id from the cache or Mongo, and if it isn't in the cache yet, adds it the cache
  1055. *
  1056. * @param {object} payload - object that contains the payload
  1057. * @param {string} payload.playlistId - the id of the playlist we are trying to get
  1058. * @returns {Promise} - returns promise (reject, resolve)
  1059. */
  1060. GET_PLAYLIST(payload) {
  1061. return new Promise((resolve, reject) => {
  1062. async.waterfall(
  1063. [
  1064. next => {
  1065. CacheModule.runJob(
  1066. "HGET",
  1067. {
  1068. table: "playlists",
  1069. key: payload.playlistId
  1070. },
  1071. this
  1072. )
  1073. .then(playlist => next(null, playlist))
  1074. .catch(next);
  1075. },
  1076. (playlist, next) => {
  1077. if (playlist)
  1078. PlaylistsModule.playlistModel.exists({ _id: payload.playlistId }, (err, exists) => {
  1079. if (err) next(err);
  1080. else if (exists) next(null, playlist);
  1081. else {
  1082. CacheModule.runJob(
  1083. "HDEL",
  1084. {
  1085. table: "playlists",
  1086. key: payload.playlistId
  1087. },
  1088. this
  1089. )
  1090. .then(() => next())
  1091. .catch(next);
  1092. }
  1093. });
  1094. else PlaylistsModule.playlistModel.findOne({ _id: payload.playlistId }, next);
  1095. },
  1096. (playlist, next) => {
  1097. if (playlist) {
  1098. CacheModule.runJob(
  1099. "HSET",
  1100. {
  1101. table: "playlists",
  1102. key: payload.playlistId,
  1103. value: playlist
  1104. },
  1105. this
  1106. )
  1107. .then(playlist => {
  1108. next(null, playlist);
  1109. })
  1110. .catch(next);
  1111. } else next("Playlist not found");
  1112. }
  1113. ],
  1114. (err, playlist) => {
  1115. if (err && err !== true) return reject(new Error(err));
  1116. return resolve(playlist);
  1117. }
  1118. );
  1119. });
  1120. }
  1121. /**
  1122. * Gets a playlist from id from Mongo and updates the cache with it
  1123. *
  1124. * @param {object} payload - object that contains the payload
  1125. * @param {string} payload.playlistId - the id of the playlist we are trying to update
  1126. * @returns {Promise} - returns promise (reject, resolve)
  1127. */
  1128. UPDATE_PLAYLIST(payload) {
  1129. return new Promise((resolve, reject) => {
  1130. async.waterfall(
  1131. [
  1132. next => {
  1133. PlaylistsModule.playlistModel.findOne({ _id: payload.playlistId }, next);
  1134. },
  1135. (playlist, next) => {
  1136. if (!playlist) {
  1137. CacheModule.runJob("HDEL", {
  1138. table: "playlists",
  1139. key: payload.playlistId
  1140. });
  1141. return next("Playlist not found");
  1142. }
  1143. return CacheModule.runJob(
  1144. "HSET",
  1145. {
  1146. table: "playlists",
  1147. key: payload.playlistId,
  1148. value: playlist
  1149. },
  1150. this
  1151. )
  1152. .then(playlist => {
  1153. next(null, playlist);
  1154. })
  1155. .catch(next);
  1156. }
  1157. ],
  1158. (err, playlist) => {
  1159. if (err && err !== true) return reject(new Error(err));
  1160. return resolve(playlist);
  1161. }
  1162. );
  1163. });
  1164. }
  1165. /**
  1166. * Deletes playlist from id from Mongo and cache
  1167. *
  1168. * @param {object} payload - object that contains the payload
  1169. * @param {string} payload.playlistId - the id of the playlist we are trying to delete
  1170. * @returns {Promise} - returns promise (reject, resolve)
  1171. */
  1172. DELETE_PLAYLIST(payload) {
  1173. return new Promise((resolve, reject) => {
  1174. async.waterfall(
  1175. [
  1176. next => {
  1177. PlaylistsModule.playlistModel.deleteOne({ _id: payload.playlistId }, next);
  1178. },
  1179. (res, next) => {
  1180. CacheModule.runJob(
  1181. "HDEL",
  1182. {
  1183. table: "playlists",
  1184. key: payload.playlistId
  1185. },
  1186. this
  1187. )
  1188. .then(() => next())
  1189. .catch(next);
  1190. },
  1191. next => {
  1192. StationsModule.runJob(
  1193. "REMOVE_AUTOFILLED_OR_BLACKLISTED_PLAYLIST_FROM_STATIONS",
  1194. { playlistId: payload.playlistId },
  1195. this
  1196. )
  1197. .then(() => {
  1198. next();
  1199. })
  1200. .catch(err => next(err));
  1201. }
  1202. ],
  1203. err => {
  1204. if (err && err !== true) return reject(new Error(err));
  1205. return resolve();
  1206. }
  1207. );
  1208. });
  1209. }
  1210. /**
  1211. * Searches through playlists
  1212. *
  1213. * @param {object} payload - object that contains the payload
  1214. * @param {string} payload.query - the query
  1215. * @param {string} payload.includePrivate - include private playlists
  1216. * @param {string} payload.includeStation - include station playlists
  1217. * @param {string} payload.includeUser - include user playlists
  1218. * @param {string} payload.includeGenre - include genre playlists
  1219. * @param {string} payload.includeAdmin - include admin playlists
  1220. * @param {string} payload.includeOwn - include own user playlists
  1221. * @param {string} payload.userId - the user id of the person requesting
  1222. * @param {string} payload.includeSongs - include songs
  1223. * @param {string} payload.page - page (default 1)
  1224. * @returns {Promise} - returns promise (reject, resolve)
  1225. */
  1226. SEARCH(payload) {
  1227. return new Promise((resolve, reject) => {
  1228. async.waterfall(
  1229. [
  1230. next => {
  1231. const types = [];
  1232. if (payload.includeStation) types.push("station");
  1233. if (payload.includeUser) types.push("user");
  1234. if (payload.includeGenre) types.push("genre");
  1235. if (payload.includeAdmin) types.push("admin");
  1236. if (types.length === 0 && !payload.includeOwn) return next("No types have been included.");
  1237. const privacies = ["public"];
  1238. if (payload.includePrivate) privacies.push("private");
  1239. const includeObject = payload.includeSongs ? null : { songs: false };
  1240. const filterArray = [
  1241. {
  1242. displayName: new RegExp(`${payload.query}`, "i"),
  1243. privacy: { $in: privacies },
  1244. type: { $in: types }
  1245. }
  1246. ];
  1247. if (payload.includeOwn && payload.userId)
  1248. filterArray.push({
  1249. displayName: new RegExp(`${payload.query}`, "i"),
  1250. type: "user",
  1251. createdBy: payload.userId
  1252. });
  1253. return next(null, filterArray, includeObject);
  1254. },
  1255. (filterArray, includeObject, next) => {
  1256. const page = payload.page ? payload.page : 1;
  1257. const pageSize = 15;
  1258. const skipAmount = pageSize * (page - 1);
  1259. PlaylistsModule.playlistModel.find({ $or: filterArray }).count((err, count) => {
  1260. if (err) next(err);
  1261. else {
  1262. PlaylistsModule.playlistModel
  1263. .find({ $or: filterArray }, includeObject)
  1264. .skip(skipAmount)
  1265. .limit(pageSize)
  1266. .exec((err, playlists) => {
  1267. if (err) next(err);
  1268. else {
  1269. next(null, {
  1270. playlists,
  1271. page,
  1272. pageSize,
  1273. skipAmount,
  1274. count
  1275. });
  1276. }
  1277. });
  1278. }
  1279. });
  1280. },
  1281. (data, next) => {
  1282. if (data.playlists.length > 0) next(null, data);
  1283. else next("No playlists found");
  1284. }
  1285. ],
  1286. (err, data) => {
  1287. if (err && err !== true) return reject(new Error(err));
  1288. return resolve(data);
  1289. }
  1290. );
  1291. });
  1292. }
  1293. /**
  1294. * Clears and refills a station playlist
  1295. *
  1296. * @param {object} payload - object that contains the payload
  1297. * @param {string} payload.playlistId - the id of the playlist we are trying to clear and refill
  1298. * @returns {Promise} - returns promise (reject, resolve)
  1299. */
  1300. CLEAR_AND_REFILL_STATION_PLAYLIST(payload) {
  1301. return new Promise((resolve, reject) => {
  1302. const { playlistId } = payload;
  1303. async.waterfall(
  1304. [
  1305. next => {
  1306. PlaylistsModule.runJob("GET_PLAYLIST", { playlistId }, this)
  1307. .then(playlist => {
  1308. next(null, playlist);
  1309. })
  1310. .catch(err => {
  1311. next(err);
  1312. });
  1313. },
  1314. (playlist, next) => {
  1315. if (playlist.type !== "station") next("This playlist is not a station playlist.");
  1316. else next(null, playlist.createdFor);
  1317. },
  1318. (stationId, next) => {
  1319. PlaylistsModule.runJob("AUTOFILL_STATION_PLAYLIST", { stationId }, this)
  1320. .then(() => {
  1321. next();
  1322. })
  1323. .catch(err => {
  1324. next(err);
  1325. });
  1326. }
  1327. ],
  1328. err => {
  1329. if (err && err !== true) return reject(new Error(err));
  1330. return resolve();
  1331. }
  1332. );
  1333. });
  1334. }
  1335. /**
  1336. * Clears and refills a genre playlist
  1337. *
  1338. * @param {object} payload - object that contains the payload
  1339. * @param {string} payload.playlistId - the id of the playlist we are trying to clear and refill
  1340. * @returns {Promise} - returns promise (reject, resolve)
  1341. */
  1342. CLEAR_AND_REFILL_GENRE_PLAYLIST(payload) {
  1343. return new Promise((resolve, reject) => {
  1344. const { playlistId } = payload;
  1345. async.waterfall(
  1346. [
  1347. next => {
  1348. PlaylistsModule.runJob("GET_PLAYLIST", { playlistId }, this)
  1349. .then(playlist => {
  1350. next(null, playlist);
  1351. })
  1352. .catch(err => {
  1353. next(err);
  1354. });
  1355. },
  1356. (playlist, next) => {
  1357. if (playlist.type !== "genre") next("This playlist is not a genre playlist.");
  1358. else next(null, playlist.createdFor);
  1359. },
  1360. (genre, next) => {
  1361. PlaylistsModule.runJob("AUTOFILL_GENRE_PLAYLIST", { genre, createPlaylist: true }, this)
  1362. .then(() => {
  1363. next();
  1364. })
  1365. .catch(err => {
  1366. next(err);
  1367. });
  1368. }
  1369. ],
  1370. err => {
  1371. if (err && err !== true) return reject(new Error(err));
  1372. return resolve();
  1373. }
  1374. );
  1375. });
  1376. }
  1377. }
  1378. export default new _PlaylistsModule();