|
| 1 | +#!/usr/local/bin/python3 |
| 2 | +# coding: utf-8 |
| 3 | + |
| 4 | +# YYeTsBot - ui.py |
| 5 | +# 2/8/21 17:55 |
| 6 | +# |
| 7 | + |
| 8 | +__author__ = "Benny <benny.think@gmail.com>" |
| 9 | + |
| 10 | +import PySimpleGUI as sg |
| 11 | +import json |
| 12 | + |
| 13 | +# All the stuff inside your window. |
| 14 | +channel_map = { |
| 15 | + "movie": "电影", |
| 16 | + "tv": "电视剧" |
| 17 | +} |
| 18 | + |
| 19 | +complete = { |
| 20 | + "status": 1, |
| 21 | + "info": "OK", |
| 22 | + "data": { |
| 23 | + "info": {}, |
| 24 | + "list": [ |
| 25 | + { |
| 26 | + "season_num": "1", |
| 27 | + "season_cn": "第一季", |
| 28 | + "items": {}, |
| 29 | + "formats": [ |
| 30 | + "MP4" |
| 31 | + ] |
| 32 | + } |
| 33 | + ] |
| 34 | + } |
| 35 | +} |
| 36 | + |
| 37 | +dl = { |
| 38 | + "itemid": "", |
| 39 | + "episode": "0", |
| 40 | + "name": "", |
| 41 | + "size": "", |
| 42 | + "yyets_trans": 0, |
| 43 | + "dateline": "1565351112", |
| 44 | + "files": [ |
| 45 | + { |
| 46 | + "way": "1", |
| 47 | + "way_cn": "电驴", |
| 48 | + "address": "", |
| 49 | + "passwd": "" |
| 50 | + }, |
| 51 | + { |
| 52 | + "way": "2", |
| 53 | + "way_cn": "磁力", |
| 54 | + "address": "", |
| 55 | + "passwd": "" |
| 56 | + }, |
| 57 | + { |
| 58 | + "way": "9", |
| 59 | + "way_cn": "网盘", |
| 60 | + "address": "", |
| 61 | + "passwd": "" |
| 62 | + }, |
| 63 | + { |
| 64 | + "way": "115", |
| 65 | + "way_cn": "微云", |
| 66 | + "address": "", |
| 67 | + "passwd": "" |
| 68 | + } |
| 69 | + ] |
| 70 | +} |
| 71 | +item_structure = { |
| 72 | + "MP4": [ |
| 73 | + ] |
| 74 | +} |
| 75 | + |
| 76 | + |
| 77 | +def get_value(): |
| 78 | + for i in range(1, int(episode_input[1].get()) + 1): |
| 79 | + d = dl.copy() |
| 80 | + d["episode"] = str(i) |
| 81 | + d["name"] = "{}{}".format(cn_input[1].get(), i) |
| 82 | + item_structure["MP4"].append(d) |
| 83 | + |
| 84 | + info_structure = { |
| 85 | + "id": 0, |
| 86 | + "cnname": cn_input[1].get(), |
| 87 | + "enname": en_input[1].get(), |
| 88 | + "aliasname": alias_input[1].get(), |
| 89 | + "channel": channel_input[1].get(), |
| 90 | + "channel_cn": channel_map.get(channel_input[1].get(), ""), |
| 91 | + "area": area_input[1].get(), |
| 92 | + "show_type": "", |
| 93 | + "expire": "1610401225", |
| 94 | + "views": 0 |
| 95 | + } |
| 96 | + |
| 97 | + complete["data"]["info"] = info_structure |
| 98 | + complete["data"]["list"] = [item_structure] |
| 99 | + |
| 100 | + with open("sample.json", "w") as f: |
| 101 | + json.dump(complete, f, indent=4, ensure_ascii=False) |
| 102 | + |
| 103 | + |
| 104 | +cn_input = [sg.Text('cn name'), sg.InputText()] |
| 105 | +en_input = [sg.Text('en name'), sg.InputText()] |
| 106 | +alias_input = [sg.Text('alias name'), sg.InputText()] |
| 107 | +channel_input = [sg.Text('channel'), sg.Combo(['movie', 'tv'], "tv")] |
| 108 | +area_input = [sg.Text('area'), sg.Combo(['美国', '日本', '韩国', '英国'], "美国")] |
| 109 | +episode_input = [sg.Text('episode count'), sg.InputText()] |
| 110 | + |
| 111 | +layout = [cn_input, en_input, alias_input, channel_input, area_input, episode_input, |
| 112 | + [sg.Button('Ok')] |
| 113 | + ] |
| 114 | + |
| 115 | +# Create the Window |
| 116 | +window = sg.Window('Management', layout) |
| 117 | +# Event Loop to process "events" and get the "values" of the inputs |
| 118 | +while True: |
| 119 | + event, values = window.read() |
| 120 | + if event == sg.WIN_CLOSED or event == 'Cancel': # if user closes window or clicks cancel |
| 121 | + break |
| 122 | + if event == "Ok": |
| 123 | + print('You entered ', values[0], values[1], values[2]) |
| 124 | + get_value() |
| 125 | + break |
| 126 | +window.close() |
0 commit comments