Skip to content

Commit

Permalink
Docs: change example in readme.md
Browse files Browse the repository at this point in the history
Use an self explanatory example (the previous one was confusing)
  • Loading branch information
jy95 committed Sep 3, 2017
1 parent 94337e1 commit a5a7e23
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 27 deletions.
54 changes: 31 additions & 23 deletions README.md
Expand Up @@ -20,37 +20,45 @@ $ yarn add torrent-files-library
const TorrentLibrary = require("torrent-files-library");

let paths = [
"D:\\DDL\\FILMS", // a path where I can find both movies and tv-series
"D:\\DDL\\SERIES TV\\Le juge et le pilote" // a path where I can find episodes of a tv-serie
"D:/DDL/FILMS", // a path where I can find both movies and tv-series
"D:\\DDL\\SERIES TV\\Le juge et le pilote" // a path where I can find episodes of a tv-serie
];

// create an instance
let libInstance = new TorrentLibrary();

// add these paths inside this lib
libInstance
.addNewPath(...paths)
.then( (message) => {
console.log(message);
return libInstance.scan();
})
.then( (otherMessage) => {
console.log(otherMessage);

setTimeout(function(){
// display the found files and their category
libInstance
.allFilesWithCategory
.forEach(function(value,key){
console.log(key + " : " + value);
});
}, 1000);
})
.catch( (err) => {
console.log(err.message);
});
.addNewPath(...paths)
.then( (message) => {
console.log(message);
return libInstance.scan();
})
.then( (otherMessage) => {
console.log(otherMessage);
console.log("I found these tv-series :");
let mapSeries = libInstance.allTvSeries;

for (let [foundTvShow,episodeSet] of mapSeries.entries() ) {
console.log("\n"+foundTvShow);
console.log("\t Total found episodes : ", episodeSet.size);
let foundSeasons = new Set([...episodeSet].map( episode => episode.season));
console.log("\t Found season(s) count : ", foundSeasons.size);
for (let seasonNumber of foundSeasons){
console.log("\t\t Season %d", seasonNumber);
let seasonEpisodes = [...episodeSet].filter(episode => episode.season === seasonNumber);
console.log("\t\t\t Season count : " + seasonEpisodes.length);
console.log("\t\t\t Files : ");
seasonEpisodes.forEach( episode => console.log("\t\t\t " + episode.filePath));
}
}

})
.catch( (err) => {
console.log(err.message);
});
```
![fileMappingDemo](https://raw.githubusercontent.com/jy95/torrent-files-library/master/demo/fileMapping.gif)
![foundTvSeries](https://raw.githubusercontent.com/jy95/torrent-files-library/master/demo/foundTvSeries.png)

## Documentation
For more examples and API details, see [API documentation](https://jy95.github.io/torrent-files-library/)
Expand Down
2 changes: 1 addition & 1 deletion docs/TorrentLibrary.html
Expand Up @@ -2603,7 +2603,7 @@ <h5>Type:</h5>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.4</a> on Sun Sep 03 2017 22:29:45 GMT+0200 (Romance Daylight Time) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.4</a> on Sun Sep 03 2017 22:48:07 GMT+0200 (Romance Daylight Time) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/TorrentLibrary.js.html
Expand Up @@ -608,7 +608,7 @@ <h1 class="page-title">TorrentLibrary.js</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.4</a> on Sun Sep 03 2017 22:29:44 GMT+0200 (Romance Daylight Time) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.4</a> on Sun Sep 03 2017 22:48:06 GMT+0200 (Romance Daylight Time) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/external-Promise.html
Expand Up @@ -139,7 +139,7 @@ <h2>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.4</a> on Sun Sep 03 2017 22:29:44 GMT+0200 (Romance Daylight Time) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.4</a> on Sun Sep 03 2017 22:48:06 GMT+0200 (Romance Daylight Time) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Expand Up @@ -183,7 +183,7 @@ <h3 id="list-each-tv-serie">
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.4</a> on Sun Sep 03 2017 22:29:44 GMT+0200 (Romance Daylight Time) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.4</a> on Sun Sep 03 2017 22:48:06 GMT+0200 (Romance Daylight Time) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down

0 comments on commit a5a7e23

Please sign in to comment.