Giter VIP home page Giter VIP logo

Comments (5)

aandroide avatar aandroide commented on June 15, 2024 1

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.

Parth-Vader avatar Parth-Vader commented on June 15, 2024

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.

aandroide avatar aandroide commented on June 15, 2024

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.

aandroide avatar aandroide commented on June 15, 2024

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.

Parth-Vader avatar Parth-Vader commented on June 15, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.