Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## **Music for Docker Developers** []( #trondiasporapsycofr_35145236_35147309a1)
- 🔴[Group Tag](https://diaspora.psyco.fr/tags/trondiasporapsycofr_35145236_35147309a1) 🔴[Pastebin](https://pastebin.com/T2jHVc4X)
- As you may know, you can develope localhost App’s using PHP-Bash web pages through [alpinedrakkar-php-bash](https://diaspora.psyco.fr/tags/trondiasporapsycofr_35145236_35147309a1) But what to do and, more importantly, how to achieve nice creations?. Suppose we want to listen to music from You Tube. We have:
- > 1 A PHP front end page, e.g. music.php (HTML-CSS topological layer)
- > 2 Javascript+Ajax to manage data (dynamic layer)
- > 3 A PHP script to trigger a bash script, e.g. searchTube.scr (connective layer)
- > 4 Hi Folks! We started … looking for Beatles music.
- > 5 Bash script (executive layer)
- Assume that the **dynamic layer** has sent data to search **beatles**. Then Bash extract it from $1 to download **beatles+music** query from youtube
- ```
- Query=$(echo "$1" music);
- curl -L "https://www.youtube.com/results?search_query=$Query" > "$1";
- ```
- Cutting the cake (beatles file) and picking only cherries (beatles2 file)
- ```
- grep -o '"url":"/watch?v=[^"]*"' $1 | sed 's/"url":"\///; s/\\.*//' >> beatles1 | sort -u beatles1 -o beatles2;
- ```
- We have got the resulting file **beatles2** with rows (68 in my case) like:
- watch?v=2Q_ZzBGPdqE
- watch?v=2RicaUqd9Hg
- watch?v=45cYwDMibGo
- **Rule**: We should code as much as we can before returning to Javascript (dynamic layer). **Bash is faste**r than Javascript or PHP.
- ```
- ##Creating a DB for The Beatles##
- mkdir "theBeatles.db";
- ##Create records for each line of the 'beatles2 file (we reserve ‘https://www.youtube.com/’ to add it in the topological layer)##
- while IFS= read -r line; do
- timestampID=$(date +"%Y%m%d%H%M%S%3N") # Generate a timestamp with milliseconds for uniqueness
- title="$1"
- echo "$timestampID|$title|$line"
- done < beatles2 > beatles.db
- ```
- We get a file with **records** like:
- 20241227160558204|Beatles_Record|watch?v=2Q_ZzBGPdqE
- 20241227160558206|Beatles_Record|watch?v=2RicaUqd9Hg
- 20241227160558207|Beatles_Record|watch?v=45cYwDMibGo
- Now we have got a **DB plain text file** for the 'dynamic layer' uses **AJAX** to perform searches and play videos **in the youtube platform** (YouTube interrupts the flow of sequences using Adds. Money, money…, and some other **virtues**!) . Using the dynamic layer you can generate results, for example, using the topological method:
- ```
- <a href="https://www.youtube.com/watch?v=2Q_ZzBGPdqE" target="_blank">Beatles</a>
- <a href="https://www.youtube.com/watch?v=2RicaUqd9Hg" target="_blank">Beatles</a>
- <a href="https://www.youtube.com/watch?v=45cYwDMibGo" target="_blank">Beatles</a>
- ```
- You can add scripts to remove records, etc.
- When are you going to publish your first **Drakkar App** here? Can we expect **even better**?
- #notas #docker #debian #linux #music
Advertisement
Add Comment
Please, Sign In to add comment