Upload to Goofile

Questions and answers on how to get the most out of FFAStrans
Post Reply
taurojo
Posts: 32
Joined: Mon Dec 19, 2016 2:44 pm

Upload to Goofile

Post by taurojo »

Regards,

I'm sharing a small Python script in this post that's very, very useful for uploading converted files to Goofile. I hope it serves you well in your projects. If you know of any way to integrate this type of script into the FFSTRANS workflow, please comment. Greetings to everyone and congratulations to the creators of this software.



https://github.com/taurojo/gofileFFASTRANS
emcodem
Posts: 1631
Joined: Wed Sep 19, 2018 8:11 am

Re: Upload to Goofile

Post by emcodem »

taurojo,

your message really hits me in a very positive way, mostly because you show initiative but also because you use github and share your stuff (welcome to the open source community my friend). Because of this, i will support you with all that i can give.

Of course as a professional programmer i have several comments to your script but i'll limit it to the most important:
  • you should not store the name of your smtp server in a public open source script
  • the script does far too much for being used in ffastrans, e.g. we have email, logging and error handling already
  • in order to avoid the need of installing python in production on ffastrans host AND to share your stuff with other users, you can use e.g. auto-py-to-exe and check "one file" to create a single exe file that executes your final script standalone

Here is my version and a test workflow that uploads the file and retrieves the link into a user_variable so it can be further in the workflow in emails, log files or whatever you want to do.
Changes to your script:
  • removed logging because we have it in ffastrans
  • removed email and related commandline params because we have it in ffastrans
  • removed error handling because we have it in ffastrans
  • the try-catch is only needed if you really "solve" an issue. You did that for sending an email but after i removed the email stuff completely, there is no need to try-catch anything anymore. If there is any error, it can be catched in the ffastrans workflow, if not the ffastrans job shows up as Error state and you can read the log in the job viewer
  • only print the retrieved download link in order to be used in ffastrans

Code: Select all

from requests_toolbelt.multipart.encoder import MultipartEncoder
import requests
import json
import sys
nameficheroData= sys.argv[1]
data = requests.get('https://apiv2.gofile.io/getServer').json()
servidorfre = (data['data']['server'])   
servidorup = "https://" + servidorfre + ".gofile.io/uploadFile"
mp_encoder = MultipartEncoder(
    fields={
        'file': (nameficheroData, open(nameficheroData, 'rb'))
    }
)
r = requests.post(servidorup,data=mp_encoder, 
    headers={'Content-Type': mp_encoder.content_type}
).json()
print ("https://gofile.io/?c="+ r['data']['code'])
Workflow for using this script:
emcodem_taurojo_test.json
(2.13 KiB) Downloaded 89 times
On a sidenote: the gofile.io service sounds too good to be true, why would someone allow sharing any filesize for unlimited time? Well, if they still work in 1-2 years i guess we can take it serious. Anyway, they state that they are in BETA phase which means one should not build a lot of dependency around their stuff. And of course closely study their terms of use and how they use your data. Also, they only support html4 multipart upload obviously which means they dont want you to upload huge files, e.g. 1GB maximum. Larger files might work but as larger it gets, the more unstable the up and download will become.
emcodem, wrapping since 2009 you got the rhyme?
taurojo
Posts: 32
Joined: Mon Dec 19, 2016 2:44 pm

Re: Upload to Goofile

Post by taurojo »

First and foremost, thank you for reviewing my humble code. I am a complete junior in programming and taking my first steps to advance in this field. Currently, I am an audiovisual technician, and although I have been programming in Python, C#, or Java for some time, since it is not my professional occupation, there is still much for me to learn. Thank you so much to people like you who help and improve our community. It is exciting.

I will review my entire code, especially the snmtp server. I have been using this code for almost two years without any problems with Gofile. I understand the concerns about licenses, but since it is hosted in France, European regulations apply. In my case, I am in Spain, so I do not think there will be much of a problem. Additionally, these videos are also published on YouTube or Facebook, so I am less concerned about Gofile than these giants.

I will undoubtedly try auto-py-to-exe. I was not aware of it, but we will test its worth.

Regarding running the code outside of FFASTRANS, it makes sense for us since we place it at the end of the queue, allowing other files to be encoded while it is processing. I understand the logic of controlling processes from FFASTRANS, but the file upload can be lengthy, and the wait time for the next encoding process could be extended. That is why I take the code outside of FFASTRANS.

Finally, I would like to thank the entire community for sharing their code. I believe it helps all of us advance. :D and let's go to test your code.

Thanks!!!
emcodem
Posts: 1631
Joined: Wed Sep 19, 2018 8:11 am

Re: Upload to Goofile

Post by emcodem »

it makes sense for us since we place it at the end of the queue, allowing other files to be encoded while it is processing.
That absolutely makes sense... we really need a checkbox in the cmd processor that allows you to exclude it from blocking a slot in the processing queue.
In that case, of course you might want to just go with your original script and add the additional parameters in the cmd executor that i sent.
Additionaly we must make the command to appear finished immediately for ffastrans but stay running in the background which you can do by just writing start before python in the cmd processor.
Something like this should do it:

Code: Select all

cmd /C "start python "C:\dev\taurojo\gofileFFASTRANS\gofileFFASTRANS.py" "%s_source%""
emcodem, wrapping since 2009 you got the rhyme?
Post Reply