publish.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. #####################################################################
  2. # #
  3. # THIS IS A SOURCE CODE FILE FROM A PROGRAM TO INTERACT WITH THE #
  4. # LBRY PROTOCOL ( lbry.com ). IT WILL USE THE LBRY SDK ( lbrynet ) #
  5. # FROM THEIR REPOSITORY ( https://github.com/lbryio/lbry-sdk ) #
  6. # WHICH I GONNA PRESENT TO YOU AS A BINARY. SINCE I DID NOT DEVELOP #
  7. # IT AND I'M LAZY TO INTEGRATE IN A MORE SMART WAY. THE SOURCE CODE #
  8. # OF THE SDK IS AVAILABLE IN THE REPOSITORY MENTIONED ABOVE. #
  9. # #
  10. # ALL THE CODE IN THIS REPOSITORY INCLUDING THIS FILE IS #
  11. # (C) J.Y.Amihud and Other Contributors 2021. EXCEPT THE LBRY SDK. #
  12. # YOU CAN USE THIS FILE AND ANY OTHER FILE IN THIS REPOSITORY UNDER #
  13. # THE TERMS OF GNU GENERAL PUBLIC LICENSE VERSION 3 OR ANY LATER #
  14. # VERSION. TO FIND THE FULL TEXT OF THE LICENSE GO TO THE GNU.ORG #
  15. # WEBSITE AT ( https://www.gnu.org/licenses/gpl-3.0.html ). #
  16. # #
  17. # THE LBRY SDK IS UNFORTUNATELY UNDER THE MIT LICENSE. IF YOU ARE #
  18. # NOT INTENDING TO USE MY CODE AND JUST THE SDK. YOU CAN FIND IT ON #
  19. # THEIR OFFICIAL REPOSITORY ABOVE. THEIR LICENSE CHOICE DOES NOT #
  20. # SPREAD ONTO THIS PROJECT. DON'T GET A FALSE ASSUMPTION THAT SINCE #
  21. # THEY USE A PUSH-OVER LICENSE, I GONNA DO THE SAME. I'M NOT. #
  22. # #
  23. # THE LICENSE CHOSEN FOR THIS PROJECT WILL PROTECT THE 4 ESSENTIAL #
  24. # FREEDOMS OF THE USER FURTHER, BY NOT ALLOWING ANY WHO TO CHANGE #
  25. # THE LICENSE AT WILL. SO NO PROPRIETARY SOFTWARE DEVELOPER COULD #
  26. # TAKE THIS CODE AND MAKE THEIR USER-SUBJUGATING SOFTWARE FROM IT. #
  27. # #
  28. #####################################################################
  29. import os
  30. import time
  31. import json
  32. import random
  33. import threading
  34. import mimetypes
  35. import urllib.request
  36. from gi.repository import Gtk
  37. from gi.repository import Gdk
  38. from gi.repository import GLib
  39. from gi.repository import Pango
  40. from gi.repository import GdkPixbuf
  41. from flbry import markdown
  42. from flbry import ui
  43. from flbry import fetch
  44. from flbry import settings
  45. ##################################################################
  46. # This file touches publication to LBRY network. #
  47. ##################################################################
  48. def lbryname(name="", force=True):
  49. # This creates a random string of characters.
  50. good = "qwertyuiopasdfghjklzxcvbnm-_QWERTYUIOPASDFGHJKLZXCVBNM1234567890"
  51. if not name and force:
  52. for i in range(70):
  53. name = name + random.choice(good)
  54. return name
  55. # This removes all non-good characters from the name
  56. new_name = ""
  57. for i in name:
  58. if i in good:
  59. new_name = new_name + i
  60. else:
  61. new_name = new_name + "_"
  62. return new_name
  63. DEFAULT_DATA = {"name":"",
  64. "bid":0.001,
  65. "file_path":"",
  66. "title":"",
  67. "license":"",
  68. "license_url":"",
  69. "thumbnail_url":"",
  70. "channel_id":"",
  71. "channel_name":"",
  72. "description":"",
  73. "fee_amount":0,
  74. "tags":[]
  75. }
  76. LICENSES = [
  77. # NAME , URL , COMMENT
  78. ["GNU General Public License Version 3 (or later)",
  79. "https://www.gnu.org/licenses/gpl-3.0.html",
  80. "Strong Copyleft. Recommended for Software."],
  81. ["GNU General Public License Version 3 (only)",
  82. "https://www.gnu.org/licenses/gpl-3.0.html",
  83. "Strong Copyleft."],
  84. ["GNU Free Documentation License",
  85. "https://www.gnu.org/licenses/fdl-1.3.html",
  86. "Strong Copyleft. Recommended for books."],
  87. ["Creative Commons Attribution-ShareAlike 4.0 International",
  88. "https://creativecommons.org/licenses/by-sa/4.0/",
  89. "Copylefted, Recommended for Art."],
  90. ["Creative Commons Attribution 4.0 International",
  91. "https://creativecommons.org/licenses/by/4.0/",
  92. "Non Copylefted, Free License."],
  93. ["Creative Commons Zero 1.0 International",
  94. "https://creativecommons.org/publicdomain/zero/1.0/",
  95. "Public Domain"],
  96. ["Creative Commons Attribution-NoDerivatives 4.0 International",
  97. "https://creativecommons.org/licenses/by-nd/4.0/",
  98. "Does not allow changes. Recommended for opinion pieces."]
  99. ]
  100. def window(win, data=DEFAULT_DATA):
  101. # First, the data recieved could be not full.
  102. for i in DEFAULT_DATA:
  103. if i not in data:
  104. data[i] = DEFAULT_DATA[i]
  105. # Upload window
  106. dialogWindow = Gtk.Dialog("Publish",
  107. buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
  108. Gtk.STOCK_OK, Gtk.ResponseType.OK),
  109. )
  110. box = dialogWindow.get_content_area()
  111. #######################################################################
  112. # #
  113. # PRESETS #
  114. # #
  115. #######################################################################
  116. #making sure the folder exists
  117. try:
  118. os.mkdir(settings.get_settings_folder()+"presets")
  119. except:
  120. pass
  121. presets_list = []
  122. for i in os.listdir(settings.get_settings_folder()+"presets"):
  123. if i.endswith(".json"):
  124. presets_list.append(i.replace(".json", ""))
  125. def on_set_preset(w):
  126. # This might be a little long one, but to hell with it.
  127. ######################################################
  128. pn = presets_list[presets.get_active()]
  129. # Opening the preset's json.
  130. with open(settings.get_settings_folder()+"presets/"+pn+'.json') as f:
  131. pdata = json.load(f)
  132. # The data should be very similar. It was saved ( hopefully ) from
  133. # the same data as what we use to publish.
  134. exclude = ["name", "file_path", "tags"]
  135. for d in pdata:
  136. if d in exclude:
  137. continue
  138. data[d] = pdata[d]
  139. # Now let's update the UI itself
  140. # THIS SHOULD NOT RUN BEFORE THE UI IS FULLY LOADED !!!
  141. # BID
  142. bid_entry.set_value(data["bid"])
  143. # TITLE
  144. title.set_text(data["title"])
  145. # LICENSE
  146. for n, ch in enumerate(LICENSES):
  147. if data["license"] == ch[0]:
  148. licenses.set_active(n)
  149. # THUMBNAIL_URL
  150. thumbentry.set_text(data["thumbnail_url"])
  151. refresh_thumb()
  152. # CHANNEL_NAME
  153. try:
  154. for n, ch in enumerate(win.my_channels["items"]):
  155. if data["channel_name"] == ch["name"] or \
  156. data["channel_id"] == ch["claim_id"]:
  157. select = n+1
  158. channels_select.set_active(select)
  159. except:
  160. pass
  161. # DESCRIPTION
  162. detext.get_buffer().set_text(data["description"])
  163. # FEE_AMOUNT
  164. price_entry.set_value(data["fee_amount"])
  165. # TAGS
  166. # Tags ( because of the tags editor ) is a special case
  167. # and we need to do this, so not to create a separate id()
  168. # for the tags list. ( Tags editor is a separate function
  169. # that accesses the same list and edit's it.
  170. # First we need to remove all of the data.
  171. tags = data["tags"].copy()
  172. for t in tags:
  173. data["tags"].remove(t)
  174. # And now we want to add all of the tags one by one.
  175. for t in pdata["tags"]:
  176. data["tags"].append(t)
  177. # And finally we want to give commands obtained from the tags
  178. # object to update it visually.
  179. for i in tagsbox.get_children():
  180. i.destroy()
  181. for tag in data["tags"]:
  182. add_tag(tag)
  183. presbox = Gtk.HBox()
  184. box.pack_start(presbox, False, False, 0)
  185. presbox.pack_start(Gtk.Label(" Presets: "), False, False, 0)
  186. presets = Gtk.ComboBoxText()
  187. presets.connect("changed", on_set_preset)
  188. for n, ch in enumerate(presets_list):
  189. presets.append_text(ch)
  190. presbox.pack_start(presets, True, True, 0)
  191. #####################################################################
  192. presetsave = Gtk.Popover()
  193. addb = Gtk.MenuButton(popover=presetsave)
  194. addb.set_relief(Gtk.ReliefStyle.NONE)
  195. addb.add(ui.icon(win, "list-add"))
  196. presbox.pack_start(addb, False, False, 0)
  197. psavebox = Gtk.VBox()
  198. presetsave.add(psavebox)
  199. pname = Gtk.Entry()
  200. pname.set_text("name")
  201. psavebox.pack_start(pname, False, False, False)
  202. def save_preset(w):
  203. update_data() # Making sure all data is in 'data'
  204. pn = pname.get_text()
  205. # Write the json file
  206. with open(settings.get_settings_folder()+"presets/"+pn+'.json', 'w') as f:
  207. json.dump(data, f, indent=4, sort_keys=True)
  208. # Add the preset into presets
  209. if pn not in presets_list:
  210. presets.append_text(pn)
  211. presets_list.append(pn)
  212. # Select the current preset
  213. for n, ch in enumerate(presets_list):
  214. if ch == pn:
  215. presets.set_active(n)
  216. presets.grab_focus() # Closing the menu
  217. pname.set_text("name")
  218. psave = Gtk.Button("Save")
  219. psave.connect("clicked", save_preset)
  220. pname.connect("activate", save_preset)
  221. psave.set_relief(Gtk.ReliefStyle.NONE)
  222. psavebox.pack_start(psave, False, False, False)
  223. psavebox.show_all()
  224. #######################################################################
  225. # #
  226. # LBRY URL PART #
  227. # #
  228. #######################################################################
  229. box.pack_start(Gtk.Label(" Channel | LBRY url "), False, True, 5)
  230. urlbox = Gtk.HBox()
  231. box.pack_start(urlbox, False, False, 0)
  232. urlbox.pack_start(Gtk.Label(" lbry:// "), False, False, 0)
  233. # This will work separately from the main channel selector, though it
  234. # will be influenced by the main channel selector a bit.
  235. def on_channel_changed(w):
  236. ch = channels_select.get_active() - 1
  237. if ch == -1:
  238. data["channel_name"] = ""
  239. data["channel_id"] = ""
  240. else:
  241. data["channel_name"] = win.my_channels["items"][ch]["name"]
  242. data["channel_id"] = win.my_channels["items"][ch]["claim_id"]
  243. channels_select = Gtk.ComboBoxText()
  244. channels_select.connect("changed", on_channel_changed)
  245. # Let's get a list of channels to show
  246. channels = ["[anonymous]"]
  247. select = 0
  248. try: # could be no channel. So publication only anonymous
  249. for n, ch in enumerate(win.my_channels["items"]):
  250. channels.append(ch["name"]+":"+ch["claim_id"][0])
  251. if data["channel_name"] == ch["name"] or \
  252. data["channel_id"] == ch["claim_id"] or \
  253. win.channel["claim_id"] == ch["claim_id"]:
  254. select = n+1
  255. except Exception as e:
  256. print("DAMN!", e)
  257. for ch in channels:
  258. channels_select.append_text(ch)
  259. channels_select.set_active(select)
  260. urlbox.pack_start(channels_select, False, False, 0)
  261. urlbox.pack_start(Gtk.Label(" / "), False, False, 0)
  262. def on_url(w):
  263. url_field.set_text(lbryname(url_field.get_text(), force=False))
  264. url_field = Gtk.Entry()
  265. url_field.connect("changed", on_url)
  266. url_field.set_text(data["name"])
  267. urlbox.pack_start(url_field, True, True, 0)
  268. #######################################################################
  269. # #
  270. # THUMBNAIL #
  271. # #
  272. #######################################################################
  273. box.pack_start(Gtk.HSeparator(), False, False, 5)
  274. thumb_file_box = Gtk.HBox()
  275. box.pack_start(thumb_file_box, False, False, 0)
  276. ######################################################################
  277. thumbvbox = Gtk.VBox()
  278. thumb_file_box.pack_start(thumbvbox, False, False, 0)
  279. def refresh_thumb():
  280. if thumbentry.get_text():
  281. t = ui.load(win, ui.net_image_calculation, ui.net_image_render, thumbentry.get_text(), 300, "FORCELOAD", True)
  282. for ch in thumbbox.get_children():
  283. ch.destroy()
  284. thumbbox.pack_start(t, True, True, 0)
  285. thumbbox.show_all()
  286. def on_thumb(w):
  287. ans = ui.select_file(data["thumbnail_url"], filter=["*jpg", "*png", "*webp", "*gif"])
  288. if ans:
  289. thumbentry.set_text(ans)
  290. refresh_thumb()
  291. thumb = Gtk.Button()
  292. thumb.connect("clicked", on_thumb)
  293. thumb.set_size_request(300,300)
  294. thumb.set_relief(Gtk.ReliefStyle.NONE)
  295. thumbbox = Gtk.HBox()
  296. thumbbox.pack_start(ui.icon(win, "image-x-generic"), False, True, 0)
  297. thumbbox.pack_start(Gtk.Label(" Thumbnail "), False, True, 0)
  298. thumb.add(thumbbox)
  299. thumbvbox.pack_start(thumb, False, False, 0)
  300. def on_toggle(w):
  301. thumbentry.set_visible(w.get_active())
  302. thumb.set_visible(not w.get_active())
  303. refresh_thumb()
  304. manually = Gtk.ToggleButton("Set thumbnail manually")
  305. manually.connect("clicked", on_toggle)
  306. manually.set_relief(Gtk.ReliefStyle.NONE)
  307. thumbvbox.pack_end(manually, False, False, 0)
  308. thumbentry = Gtk.Entry()
  309. thumbentry.set_text(data["thumbnail_url"])
  310. refresh_thumb()
  311. thumbvbox.pack_end(thumbentry, False, False, 0)
  312. thumb_file_box.pack_start(Gtk.VSeparator(), False, False, 5)
  313. #######################################################################
  314. # #
  315. # TITLE #
  316. # #
  317. #######################################################################
  318. filebox = Gtk.VBox()
  319. thumb_file_box.pack_start(filebox, True, True, 0)
  320. #######################################################################
  321. titlebox = Gtk.HBox()
  322. filebox.pack_start(titlebox, False, False, 5)
  323. titlebox.pack_start(Gtk.Label(" Title: "), False, False, False)
  324. def on_title(w):
  325. data["title"] = title.get_text()
  326. title = Gtk.Entry()
  327. title.set_text(data["title"])
  328. title.connect("changed", on_title)
  329. titlebox.pack_start(title, True, True, False)
  330. #######################################################################
  331. # #
  332. # FILE #
  333. # #
  334. #######################################################################
  335. def choose_file(filename=""):
  336. for ch in filebbox.get_children():
  337. ch.destroy()
  338. if filename:
  339. icon_is = mimetypes.guess_type(filename)[0].replace("/", "-")
  340. name_of_file = filename[filename.rfind("/")+1:]
  341. def clear_name(name):
  342. name = name[:name.rfind(".")]
  343. name = name.replace("_", " ")
  344. try:
  345. name = name[0].upper()+name[1:]
  346. except:
  347. pass
  348. return name
  349. ofilename = data["file_path"]
  350. if not title.get_text() or clear_name(ofilename[ofilename.rfind("/")+1:]) == title.get_text():
  351. title.set_text(clear_name(name_of_file))
  352. data["title"] = clear_name(name_of_file)
  353. if not url_field.get_text() or lbryname(clear_name(ofilename[ofilename.rfind("/")+1:])) == url_field.get_text():
  354. url_field.set_text(lbryname(title.get_text(), force=True))
  355. else:
  356. icon_is = "document-open"
  357. name_of_file = "Choose File"
  358. filebbox.pack_start(ui.icon(win, icon_is), False, True, 0)
  359. filebbox.pack_start(Gtk.Label(" "+name_of_file+" "), False, True, 0)
  360. filebbox.show_all()
  361. def on_filebutton(w):
  362. name = ui.select_file(data["file_path"])
  363. choose_file(name)
  364. data["file_path"] = name
  365. filebutton = Gtk.Button()
  366. filebutton.connect("clicked", on_filebutton)
  367. filebbox = Gtk.HBox()
  368. filebutton.add(filebbox)
  369. choose_file(data["file_path"])
  370. filebutton.set_relief(Gtk.ReliefStyle.NONE)
  371. filebox.pack_start(filebutton, False, False, 0)
  372. box.pack_start(Gtk.HSeparator(), False, False, 5)
  373. #######################################################################
  374. # #
  375. # BID #
  376. # #
  377. #######################################################################
  378. bid_adjust = Gtk.Adjustment(data["bid"],
  379. lower=0.0001,
  380. upper=1000000000,
  381. step_increment=0.1)
  382. bid_entry = Gtk.SpinButton(adjustment=bid_adjust,
  383. digits=4)
  384. bid_box = Gtk.HBox()
  385. filebox.pack_start(bid_box, False, False, 5)
  386. bid_box.pack_start(Gtk.Label(" Bid: "), False, False, 0)
  387. bid_box.pack_end(bid_entry, False, False, 0)
  388. #######################################################################
  389. # #
  390. # PRICE #
  391. # #
  392. #######################################################################
  393. price_adjust = Gtk.Adjustment(data["fee_amount"],
  394. lower=0,
  395. upper=1000000000,
  396. step_increment=0.1)
  397. price_entry = Gtk.SpinButton(adjustment=price_adjust,
  398. digits=4)
  399. price_box = Gtk.HBox()
  400. filebox.pack_start(price_box, False, False, 5)
  401. price_box.pack_start(Gtk.Label(" Price: "), False, False, 0)
  402. price_box.pack_end(price_entry, False, False, 0)
  403. #######################################################################
  404. # #
  405. # DESCRIPTION #
  406. # #
  407. #######################################################################
  408. filebox.pack_start(Gtk.Label(" Description: "), False, True, 5)
  409. descrl = Gtk.ScrolledWindow()
  410. detext = Gtk.TextView()
  411. detext.set_wrap_mode(Gtk.WrapMode.WORD)
  412. detext.get_buffer().set_text(data["description"])
  413. descrl.add(detext)
  414. filebox.pack_start(descrl, True, True, 0)
  415. #######################################################################
  416. # #
  417. # TAGS #
  418. # #
  419. #######################################################################
  420. box.pack_start(Gtk.Label(" Tags "), False, True, 5)
  421. tags_editor, tagsbox, add_tag = ui.tags_editor(win, data["tags"], return_edit_functions=True)
  422. box.pack_start(tags_editor, False, False, 0)
  423. #######################################################################
  424. # #
  425. # LICENSE #
  426. # #
  427. #######################################################################
  428. box.pack_start(Gtk.Label(" License "), False, True, 5)
  429. def on_license(w):
  430. l = licenses.get_active()
  431. data["license"] = LICENSES[l][0]
  432. data["license_url"] = LICENSES[l][1]
  433. licenses = Gtk.ComboBoxText()
  434. licenses.connect("changed", on_license)
  435. for n, ch in enumerate(LICENSES):
  436. licenses.append_text(ch[0])
  437. if data["license"] == ch[0]:
  438. licenses.set_active(n)
  439. box.pack_start(licenses, False, True, 0)
  440. #######################################################################
  441. # #
  442. # RUNING THE SETTINGS DIALOG #
  443. # #
  444. #######################################################################
  445. box.show_all()
  446. def update_data():
  447. # Not all widgets update data automatically. We need this function
  448. # whenever we want the up-to-date data.
  449. data["name"] = url_field.get_text()
  450. data["thumbnail_url"] = thumbentry.get_text()
  451. data["bid"] = bid_entry.get_value()
  452. data["fee_amount"] = price_entry.get_value()
  453. tb = detext.get_buffer()
  454. data["description"] = tb.get_text(tb.get_start_iter(), tb.get_end_iter(), True)
  455. # Hide all hidden
  456. thumbentry.set_visible(False)
  457. response = dialogWindow.run()
  458. if response == Gtk.ResponseType.OK:
  459. update_data()
  460. print("\n\n############## PUBLISH INPUT ###########\n\n{")
  461. for i in data:
  462. print(' "'+i+'" :', data[i])
  463. print("}\n")
  464. out = upload(data)
  465. print("\n\n############## PUBLISH OUTPUT ###########\n\n")
  466. print(out)
  467. try:
  468. ui.notify(win, "Published successfully to: ", out['outputs'][0]['permanent_url']+"\n\nConfirming...")
  469. except:
  470. try:
  471. ui.notify(win, "Error while publishing!!!", out["message"])
  472. except:
  473. ui.notify(win, "Error while publishing!!!", str(out))
  474. # It has to be DESTORYED
  475. dialogWindow.destroy()
  476. def upload(data):
  477. ###############################################################
  478. # PUBLISH ! PUBLISH ! PUBLISH ! PUBLISH ! PUBLISH ! PUBLISH ! #
  479. ###############################################################
  480. # The required datapoints
  481. fetch_data = {"name":data["name"],
  482. "bid":str(float(data["bid"])),
  483. "file_path":data["file_path"]}
  484. # Uploading the thumbnail maybe
  485. data["thumbnail_url"] = speech_upload(data["thumbnail_url"])
  486. for i in ["title", "license", "license_url", "thumbnail_url", "description", "channel_name", "fee_amount", "tags"]:
  487. if i in data:
  488. if data[i]:
  489. if type(data[i]) not in [float, int]:
  490. fetch_data[i] = data[i]
  491. else:
  492. fetch_data[i] = str(float(data[i]))
  493. if data["fee_amount"]:
  494. fetch_data["fee_currency"] = "LBC"
  495. out = fetch.lbrynet("publish", fetch_data)
  496. return out
  497. def speech_upload(file, name="", fee=0, speech=True):
  498. file = os.path.expanduser(file)
  499. if os.path.isfile(file):
  500. print("Uploading '"+file+"' to LBRY")
  501. if not name:
  502. rndname = ""
  503. else:
  504. rndname = name + "_"
  505. length = 70 - len(rndname)
  506. good = "qwertyuiopasdfghjklzxcvbnm-_QWERTYUIOPASDFGHJKLZXCVBNM1234567890"
  507. for i in range(length):
  508. rndname = rndname + random.choice(good)
  509. try:
  510. out = upload({"name":rndname,
  511. "bid":0.001,
  512. "file_path":file,
  513. "title":"",
  514. "license":"",
  515. "license_url":"",
  516. "thumbnail_url":"",
  517. "channel_id":"",
  518. "channel_name":"",
  519. "description":"",
  520. "fee_amount":fee,
  521. "tags":[]
  522. })
  523. if speech:
  524. return out['outputs'][0]['permanent_url'].replace("lbry://","https://spee.ch/")
  525. else:
  526. return out['outputs'][0]['permanent_url']
  527. except:
  528. return ""
  529. else:
  530. return file