Comments (5)
hi, I think I understand now.
in your script, first download the mp3 file to the temporary folder you create and then send it to the device and delete the folder in order to have a single file in the folder when the file is sent.
correct?
I'm using sdk assistant on raspberry and the download function that I ceato is used to do everything automatically so I'm forced to use the timer since I have to wait for youtube dl to convert the requested file.
I was thinking if I could improve this piece of code but I know that it is the most valid.
Thanks for your help
from moboff.
I didn't get your question, what do you mean when you say that you want to send the file automatically in place of programmatically?
In my implementation, the whole process is a single one - you add an URL, and the file is downloaded, converted and sent to your phone via Pushbullet.
from moboff.
hello, I meant that for now I can get the mp3 file, only if I say so ':
with open (home / pi / Music / file.mp3, "rb") as song:
file_data = pb.upload_file (song, home / pi / Music / file.mp3)
push = pb.push_file (** file_data)
while in your script you declared file:
with open(file, "rb") as song:
file_data = pb.upload_file(song, file)
push = pb.push_file(**file_data)
what I wanted to know is how did you declare the file variable that sends the mp3 file just extracted from youtube-dl?
in my case I use the home / pi / Music folder to save the mp3 files extracted from youtube-dl
Thank you for your help
from moboff.
I succeeded, but I would like to eliminate the timer that I had to put in order to wait for the file to be extracted in mp3.
some advice?
this is my script:
def download(phrase):
subprocess.Popen(["/usr/bin/youtube-dl",'-o','Music/%(title)s.%(ext)s','--batch-file','lista.txt','--extract-audio','--audio-format=mp3','--audio-quality','0'],stdin=subprocess.PIPE,stdout=subprocess.PIPE)
say("download della traccia in corso")
time.sleep(100) # Attende 100 secondi
types = ('*.mp3', '*.mp4', '*.mkv')
list_of_files = glob.glob('/home/pi/Music/*.mp3')
recent_download = max(
list_of_files,
key=os.path.getctime)
with open(recent_download, "rb") as song:
file_data = pb.upload_file(song, recent_download)
push = pb.push_file(**file_data)
from moboff.
Cool, I understood your query.
First of all, I store the actual place where I want to put my music files. Then, I create a temp folder and change to that folder. Then I search for .mp3 or other Video formats
via glob
and send it to my device. This way, you don't have to search again and again for the most recent downloaded file.
After successfully sending it to the device, I move the files from the temp folder to the actual folder and delete the temp folder.
I hope you understood my approach.
from moboff.
Related Issues (20)
- Download Playlist feature doesn't send entire playlist to the device. HOT 5
- Imports should be PEP-8 compliant HOT 2
- Send several single YouTube music files in a sequence HOT 5
- README.md instructions for Windows users
- Send downloaded file to friends
- Song suggestions HOT 1
- Detect if a song/file is already downloaded. HOT 3
- [idea] A cross-platform GUI for MobOff HOT 1
- Docker image to skip the installation process HOT 10
- Missing dependencies file HOT 2
- Missing gitignore file
- --video option breaks when used HOT 4
- real_path_of_moboff is not correct. HOT 2
- .idea file gets tracked too HOT 3
- Publishing a Docker image to DockerHub HOT 2
- Improved CLI support to pass API key & Device Id HOT 10
- moboff_config.json is made only for `moboff` path HOT 3
- Automatic build of docker image HOT 2
- What is the use? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from moboff.