tron-diasporapsycofr

dev HelloWorld

Dec 27th, 2024 (edited)
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.99 KB | Music | 0 0
  1. ## **Music for Docker Developers** []( #trondiasporapsycofr_35145236_35147309a1)
  2. 🔴[Group Tag](https://diaspora.psyco.fr/tags/trondiasporapsycofr_35145236_35147309a1) 🔴[Pastebin](https://pastebin.com/T2jHVc4X)
  3.  
  4. 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:
  5.  
  6. > 1 A PHP front end page, e.g. music.php (HTML-CSS topological layer)
  7. > 2 Javascript+Ajax to manage data (dynamic layer)
  8. > 3 A PHP script to trigger a bash script, e.g. searchTube.scr (connective layer)
  9. > 4 Hi Folks! We started … looking for Beatles music.
  10. > 5 Bash script (executive layer)
  11.  
  12. Assume that the **dynamic layer** has sent data to search **beatles**. Then Bash extract it from $1 to download **beatles+music** query from youtube
  13. ```
  14. Query=$(echo "$1" music);
  15. curl -L "https://www.youtube.com/results?search_query=$Query" > "$1";
  16. ```
  17. Cutting the cake (beatles file) and picking only cherries (beatles2 file)
  18. ```
  19. grep -o '"url":"/watch?v=[^"]*"' $1 | sed 's/"url":"\///; s/\\.*//' >> beatles1 | sort -u beatles1 -o beatles2;
  20. ```
  21.  
  22. We have got the resulting file **beatles2** with rows (68 in my case) like:
  23.  
  24.     watch?v=2Q_ZzBGPdqE
  25.     watch?v=2RicaUqd9Hg
  26.     watch?v=45cYwDMibGo
  27.  
  28. **Rule**: We should code as much as we can before returning to Javascript (dynamic layer). **Bash is faste**r than Javascript or PHP.
  29. ```
  30. ##Creating a DB for The Beatles##
  31. mkdir "theBeatles.db";
  32.  
  33. ##Create records for each line of the 'beatles2 file (we reserve ‘https://www.youtube.com/’ to add it in the topological layer)##
  34. while IFS= read -r line; do
  35. timestampID=$(date +"%Y%m%d%H%M%S%3N") # Generate a timestamp with milliseconds for uniqueness
  36. title="$1"
  37. echo "$timestampID|$title|$line"
  38. done < beatles2 > beatles.db
  39. ```
  40. We get a file with **records** like:
  41. &nbsp; &nbsp; 20241227160558204|Beatles_Record|watch?v=2Q_ZzBGPdqE
  42. &nbsp; &nbsp; 20241227160558206|Beatles_Record|watch?v=2RicaUqd9Hg
  43. &nbsp; &nbsp; 20241227160558207|Beatles_Record|watch?v=45cYwDMibGo
  44.  
  45. 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:
  46.  
  47. ```
  48. <a href="https://www.youtube.com/watch?v=2Q_ZzBGPdqE" target="_blank">Beatles</a>
  49. <a href="https://www.youtube.com/watch?v=2RicaUqd9Hg" target="_blank">Beatles</a>
  50. <a href="https://www.youtube.com/watch?v=45cYwDMibGo" target="_blank">Beatles</a>
  51. ```
  52. You can add scripts to remove records, etc.
  53.  
  54. When are you going to publish your first **Drakkar App** here? Can we expect **even better**?
  55.  
  56. #notas #docker #debian #linux #music
Tags: developers
Advertisement
Add Comment
Please, Sign In to add comment