-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
210 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: gunicorn src/main:app --log-file=- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env python3 | ||
import dropbox | ||
|
||
class TransferData: | ||
def __init__(self, access_token): | ||
self.access_token = access_token | ||
|
||
def upload_file(self, file_from=None, file_to=None): | ||
"""upload a file to Dropbox using API v2 | ||
""" | ||
dbx = dropbox.Dropbox(self.access_token) | ||
|
||
with open(file_from, 'rb') as f: | ||
dbx.files_upload(f.read(), file_to) | ||
|
||
#---------------------------------------------------------------------- | ||
def get_account_info(self): | ||
""" | ||
Returns the account information, such as user's display name, | ||
quota, email address, etc | ||
""" | ||
return self.client.account_info() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os | ||
from radiorec import record_radio | ||
from transferdata import TransferData | ||
|
||
|
||
def main(): | ||
radio_record = record_radio('http://audio.samaafm.com:8008/1') | ||
file_name = radio_record.record_radio() | ||
drop_box_access_token = os.environ.get('access_token') | ||
target_dir = os.environ.get('target_dir') | ||
upload_to = target_dir + os.sep + file_name | ||
transfer_data = TransferData(drop_box_access_token) | ||
transfer_data.get_account_info() | ||
transfer_data.upload_file(file_name, upload_to) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env python3 | ||
""" | ||
radiorec.py – Recording internet radio streams and Upload to SoundCloud | ||
Copyright (C) 2017 Muhammad Taqi <[email protected]> | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
""" | ||
|
||
# import libraries | ||
import datetime | ||
import urllib.request | ||
|
||
|
||
class record_radio: | ||
|
||
def __init__(self, stream_url): | ||
self.stream_url = stream_url | ||
|
||
def __enter__(self): | ||
print('__enter__') | ||
|
||
def __exit__(self, typ, value, tb): | ||
print('__exit__') | ||
|
||
def init(self): | ||
print("init") | ||
|
||
def start(self): | ||
print("start") | ||
|
||
def stop(self): | ||
print("stop") | ||
|
||
def finish(self): | ||
print("finish") | ||
|
||
def record_radio(self): | ||
d = datetime.date.today() | ||
filename = "recording" + d.strftime("%Y%m%d")+".ogg" | ||
stream = urllib.request.urlopen(self.stream_url) | ||
start_time = datetime.datetime.now() | ||
dest = open(filename, 'wb') | ||
while (datetime.datetime.now() - start_time).seconds <= 30: | ||
print((datetime.datetime.now() - start_time).seconds) | ||
dest.write(stream.read(1024)) | ||
return filename | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import dropbox | ||
|
||
|
||
class TransferData: | ||
|
||
def __init__(self, access_token): | ||
self.access_token = access_token | ||
|
||
def upload_file(self, file_from=None, file_to=None): | ||
""" | ||
upload a file to Dropbox using API v2 | ||
:param file_from: | ||
:param file_to: | ||
:return: | ||
""" | ||
client = dropbox.Dropbox(self.access_token) | ||
try: | ||
with open(file_from, 'rb') as f: | ||
meta = client.files_upload(f.read(), file_to, mute=True) | ||
print("Uploaded " + file_to) | ||
except: | ||
print("Failed to upload " + file_to) | ||
|
||
def get_account_info(self): | ||
""" | ||
Returns the account information, such as user's display name, quota, | ||
email address, etc | ||
:return: | ||
""" | ||
client = dropbox.Dropbox(self.access_token) | ||
print(client.users_get_current_account()) |