import MySQLdb, sys

## CONFIGURATION ##
rHost = "localhost"
rPort = 7999
rUsername = "root"
rPassword = ""
rDatabase = "xtream_iptvpro"

## QUERIES
rDelete = ["licence"]
rDrop = ["access_output", "cronjobs", "devices", "streams_arguments", "streams_types"]
rQueries = ["CREATE TABLE `created` (`id` tinyint(4) NOT NULL,`type` tinyint(4) NOT NULL,`category_id` tinyint(4) NOT NULL,`stream_display_name` tinyint(4) NOT NULL,`stream_source` tinyint(4) NOT NULL,`stream_icon` tinyint(4) NOT NULL,`notes` tinyint(4) NOT NULL,`created_channel_location` tinyint(4) NOT NULL,`enable_transcode` tinyint(4) NOT NULL,`transcode_attributes` tinyint(4) NOT NULL,`custom_ffmpeg` tinyint(4) NOT NULL,`movie_propeties` tinyint(4) NOT NULL,`movie_subtitles` tinyint(4) NOT NULL,`read_native` tinyint(4) NOT NULL,`target_container` tinyint(4) NOT NULL,`stream_all` tinyint(4) NOT NULL,`remove_subtitles` tinyint(4) NOT NULL,`custom_sid` tinyint(4) NOT NULL,`epg_id` tinyint(4) NOT NULL,`channel_id` tinyint(4) NOT NULL,`epg_lang` tinyint(4) NOT NULL,`order` tinyint(4) NOT NULL,`auto_restart` tinyint(4) NOT NULL,`transcode_profile_id` tinyint(4) NOT NULL,`pids_create_channel` tinyint(4) NOT NULL,`cchannel_rsources` tinyint(4) NOT NULL,`gen_timestamps` tinyint(4) NOT NULL,`added` tinyint(4) NOT NULL,`series_no` tinyint(4) NOT NULL,`direct_source` tinyint(4) NOT NULL,`tv_archive_duration` tinyint(4) NOT NULL,`tv_archive_server_id` tinyint(4) NOT NULL,`tv_archive_pid` tinyint(4) NOT NULL,`movie_symlink` tinyint(4) NOT NULL,`redirect_stream` tinyint(4) NOT NULL,`rtmp_output` tinyint(4) NOT NULL,`number` tinyint(4) NOT NULL,`allow_record` tinyint(4) NOT NULL,`probesize_ondemand` tinyint(4) NOT NULL,`custom_map` tinyint(4) NOT NULL,`external_push` tinyint(4) NOT NULL,`delay_minutes` tinyint(4) NOT NULL) ENGINE=MyISAM DEFAULT CHARSET=utf8;", "CREATE TABLE `credits_log` (`id` int(11) NOT NULL,`target_id` int(11) NOT NULL,`admin_id` int(11) NOT NULL,`amount` float NOT NULL,`date` int(11) NOT NULL,`reason` text NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8;", "CREATE TABLE `enigma2_actions` (`id` int(11) NOT NULL,`device_id` int(11) NOT NULL,`type` text NOT NULL,`key` text NOT NULL,`command` text NOT NULL,`command2` text NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8;", "CREATE TABLE `enigma2_devices` (`device_id` int(12) NOT NULL,`mac` varchar(255) NOT NULL,`user_id` int(11) NOT NULL,`modem_mac` varchar(255) NOT NULL,`local_ip` varchar(255) NOT NULL,`public_ip` varchar(255) NOT NULL,`key_auth` varchar(255) NOT NULL,`enigma_version` varchar(255) NOT NULL,`cpu` varchar(255) NOT NULL,`version` varchar(255) NOT NULL,`lversion` text NOT NULL,`token` varchar(32) NOT NULL,`last_updated` int(11) NOT NULL,`watchdog_timeout` int(11) NOT NULL,`lock_device` tinyint(4) NOT NULL DEFAULT '0',`telnet_enable` tinyint(4) NOT NULL DEFAULT '1',`ftp_enable` tinyint(4) NOT NULL DEFAULT '1',`ssh_enable` tinyint(4) NOT NULL DEFAULT '1',`dns` varchar(255) NOT NULL,`original_mac` varchar(255) NOT NULL,`rc` tinyint(4) NOT NULL DEFAULT '1') ENGINE=InnoDB DEFAULT CHARSET=utf8;", "CREATE TABLE `enigma2_failed` (`id` int(11) NOT NULL,`original_mac` varchar(255) NOT NULL,`virtual_mac` varchar(255) NOT NULL,`date` int(11) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8;", "CREATE TABLE `isp_addon` (`id` int(11) NOT NULL,`isp` text NOT NULL,`blocked` tinyint(4) NOT NULL DEFAULT '0') ENGINE=InnoDB DEFAULT CHARSET=utf8;", "CREATE TABLE `mag_claims` (`id` int(11) NOT NULL,`mag_id` int(11) NOT NULL,`stream_id` int(11) NOT NULL,`real_type` varchar(10) NOT NULL,`date` datetime NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8;", "CREATE TABLE `reseller_imex` (`id` int(11) NOT NULL,`reg_id` int(11) NOT NULL,`header` longtext NOT NULL,`data` longtext NOT NULL,`accepted` tinyint(4) NOT NULL DEFAULT '0',`finished` tinyint(4) NOT NULL DEFAULT '0',`bouquet_ids` text NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8;", "CREATE TABLE `rtmp_ips` (`id` int(11) NOT NULL,`ip` varchar(255) NOT NULL,`notes` text NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8;", "CREATE TABLE `series` (`id` int(11) NOT NULL,`title` varchar(255) NOT NULL,`category_id` int(11) DEFAULT NULL,`cover` varchar(255) NOT NULL,`cover_big` varchar(255) NOT NULL,`genre` varchar(255) NOT NULL,`plot` text NOT NULL,`cast` text NOT NULL,`rating` int(11) NOT NULL,`director` varchar(255) NOT NULL,`releaseDate` varchar(255) NOT NULL,`last_modified` int(11) NOT NULL,`tmdb_id` int(11) NOT NULL,`seasons` mediumtext NOT NULL,`episode_run_time` int(11) NOT NULL DEFAULT '0',`backdrop_path` text NOT NULL,`youtube_trailer` text NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8;", "CREATE TABLE `series_episodes` (`id` int(11) NOT NULL,`season_num` int(11) NOT NULL,`series_id` int(11) NOT NULL,`stream_id` int(11) NOT NULL,`sort` int(11) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8;", "CREATE TABLE `signals` (`signal_id` int(11) NOT NULL,`pid` int(11) NOT NULL,`server_id` int(11) NOT NULL,`rtmp` tinyint(4) NOT NULL DEFAULT '0',`time` int(11) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8;", "CREATE TABLE `streams_seasons` (`season_id` int(11) NOT NULL,`season_name` varchar(255) NOT NULL,`stream_id` int(11) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8;", "CREATE TABLE `stream_logs` (`id` int(11) NOT NULL,`stream_id` int(11) NOT NULL,`server_id` int(11) NOT NULL,`date` int(11) NOT NULL,`error` varchar(500) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8;", "CREATE TABLE `stream_subcategories` (`sub_id` int(11) NOT NULL,`parent_id` int(11) NOT NULL,`subcategory_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;", "CREATE TABLE `suspicious_logs` (`id` int(11) NOT NULL,`user_id` int(11) NOT NULL,`data` mediumtext NOT NULL,`last_updated` datetime NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8;", "CREATE TABLE `xtream_main` (`id` int(11) NOT NULL,`update_available` int(11) NOT NULL DEFAULT '0',`root_ip` mediumtext COLLATE utf8_unicode_ci NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;", "CREATE TABLE `access_output` (`access_output_id` int(11) NOT NULL,`output_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,`output_key` varchar(255) COLLATE utf8_unicode_ci NOT NULL,`output_ext` varchar(255) COLLATE utf8_unicode_ci NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;", "INSERT INTO `access_output` (`access_output_id`, `output_name`, `output_key`, `output_ext`) VALUES(1, 'HLS', 'm3u8', 'm3u8'),(2, 'MPEGTS', 'ts', 'ts'),(3, 'RTMP', 'rtmp', '');", "CREATE TABLE `cronjobs` (`id` int(11) NOT NULL,`description` mediumtext COLLATE utf8_unicode_ci NOT NULL,`filename` varchar(255) COLLATE utf8_unicode_ci NOT NULL,`run_per_mins` int(11) NOT NULL DEFAULT '1',`run_per_hours` int(11) NOT NULL DEFAULT '0',`enabled` int(11) NOT NULL DEFAULT '0',`pid` int(11) NOT NULL DEFAULT '0',`timestamp` int(11) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;", "CREATE TABLE `devices` (`device_id` int(11) NOT NULL,`device_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,`device_key` varchar(255) COLLATE utf8_unicode_ci NOT NULL,`device_filename` varchar(255) COLLATE utf8_unicode_ci NOT NULL,`device_header` mediumtext COLLATE utf8_unicode_ci NOT NULL,`device_conf` mediumtext COLLATE utf8_unicode_ci NOT NULL,`device_footer` mediumtext COLLATE utf8_unicode_ci NOT NULL,`default_output` int(11) NOT NULL DEFAULT '0',`copy_text` mediumtext COLLATE utf8_unicode_ci) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;", "INSERT INTO `devices` (`device_id`, `device_name`, `device_key`, `device_filename`, `device_header`, `device_conf`, `device_footer`, `default_output`, `copy_text`) VALUES(1, 'GigaBlue', 'gigablue', 'userbouquet.favourites.tv', '#NAME \{BOUQUET_NAME\}', '#SERVICE 4097:0:1:0:0:0:0:0:0:0:\{URL#:\}#DESCRIPTION \{CHANNEL_NAME\}', '', 2, NULL),(2, 'Enigma 2 OE 1.6', 'enigma16', 'userbouquet.favourites.tv', '#NAME \{BOUQUET_NAME\}', '#SERVICE 4097\{SID\}\{URL#:\}#DESCRIPTION \{CHANNEL_NAME\}', '', 2, NULL),(3, 'DreamBox OE 2.0', 'dreambox', 'userbouquet.favourites.tv', '#NAME \{BOUQUET_NAME\}', '#SERVICE \{ESR_ID\}\{SID\}\{URL#:\}#DESCRIPTION \{CHANNEL_NAME\}', '', 2, NULL),(4, 'm3u', 'm3u', 'tv_channels_\{USERNAME\}.m3u', '#EXTM3U', '#EXTINF:-1,\{CHANNEL_NAME\}\{URL\}', '', 2, NULL),(5, 'Simple List', 'simple', 'simple_\{USERNAME\}.txt', '', '\{URL\} #Name: \{CHANNEL_NAME\}', '', 2, NULL),(6, 'Octagon', 'octagon', 'internettv.feed', '', '[TITLE]\{CHANNEL_NAME\}[URL]\{URL\}[DESCRIPTION]IPTV[TYPE]Live', '', 2, NULL),(7, 'Starlive v3/StarSat HD6060/AZclass', 'starlivev3', 'iptvlist.txt', '', '\{CHANNEL_NAME\},\{URL\}', '', 2, NULL),(8, 'MediaStar / StarLive v4', 'mediastar', 'tvlist.txt', '', '\{CHANNEL_NAME\} \{URL\}', '', 2, NULL),(9, 'Enigma 2 OE 1.6 Auto Script', 'enigma216_script', 'iptv.sh', 'USERNAME=\"\{USERNAME\}\";PASSWORD=\"\{PASSWORD\}\";bouquet=\"\{BOUQUET_NAME\}\";directory=\"/etc/enigma2/iptv.sh\";url=\"\{SERVER_URL\}get.php?username=$USERNAME&password=$PASSWORD&type=enigma16&output=\{OUTPUT_KEY\}\";rm /etc/enigma2/userbouquet.\"$bouquet\"__tv_.tv;wget -O /etc/enigma2/userbouquet.\"$bouquet\"__tv_.tv $url;if ! cat /etc/enigma2/bouquets.tv | grep -v grep | grep -c $bouquet > /dev/null;then echo \"[+]Creating Folder for iptv and rehashing...\";cat /etc/enigma2/bouquets.tv | sed -n 1p > /etc/enigma2/new_bouquets.tv;echo \'#SERVICE 1:7:1:0:0:0:0:0:0:0:FROM BOUQUET \"userbouquet.\'$bouquet\'__tv_.tv\" ORDER BY bouquet\' >> /etc/enigma2/new_bouquets.tv; cat /etc/enigma2/bouquets.tv | sed -n \'2,$p\' >> /etc/enigma2/new_bouquets.tv;rm /etc/enigma2/bouquets.tv;mv /etc/enigma2/new_bouquets.tv /etc/enigma2/bouquets.tv;fi;rm /usr/bin/enigma2_pre_start.sh;echo \"writing to the file.. NO NEED FOR REBOOT\";echo \"/bin/sh \"$directory\" > /dev/null 2>&1 &\" > /usr/bin/enigma2_pre_start.sh;chmod 777 /usr/bin/enigma2_pre_start.sh;wget -qO - \"http://127.0.0.1/web/servicelistreload?mode=2\";wget -qO - \"http://127.0.0.1/web/servicelistreload?mode=2\";', '', '', 2, 'wget -O /etc/enigma2/iptv.sh \{DEVICE_LINK\} && chmod 777 /etc/enigma2/iptv.sh && /etc/enigma2/iptv.sh'),(10, 'Enigma 2 OE 2.0 Auto Script', 'enigma22_script', 'iptv.sh', 'USERNAME=\"\{USERNAME\}\";PASSWORD=\"\{PASSWORD\}\";bouquet=\"\{BOUQUET_NAME\}\";directory=\"/etc/enigma2/iptv.sh\";url=\"\{SERVER_URL\}get.php?username=$USERNAME&password=$PASSWORD&type=dreambox&output=\{OUTPUT_KEY\}\";rm /etc/enigma2/userbouquet.\"$bouquet\"__tv_.tv;wget -O /etc/enigma2/userbouquet.\"$bouquet\"__tv_.tv $url;if ! cat /etc/enigma2/bouquets.tv | grep -v grep | grep -c $bouquet > /dev/null;then echo \"[+]Creating Folder for iptv and rehashing...\";cat /etc/enigma2/bouquets.tv | sed -n 1p > /etc/enigma2/new_bouquets.tv;echo \'#SERVICE 1:7:1:0:0:0:0:0:0:0:FROM BOUQUET \"userbouquet.\'$bouquet\'__tv_.tv\" ORDER BY bouquet\' >> /etc/enigma2/new_bouquets.tv; cat /etc/enigma2/bouquets.tv | sed -n \'2,$p\' >> /etc/enigma2/new_bouquets.tv;rm /etc/enigma2/bouquets.tv;mv /etc/enigma2/new_bouquets.tv /etc/enigma2/bouquets.tv;fi;rm /usr/bin/enigma2_pre_start.sh;echo \"writing to the file.. NO NEED FOR REBOOT\";echo \"/bin/sh \"$directory\" > /dev/null 2>&1 &\" > /usr/bin/enigma2_pre_start.sh;chmod 777 /usr/bin/enigma2_pre_start.sh;wget -qO - \"http://127.0.0.1/web/servicelistreload?mode=2\";wget -qO - \"http://127.0.0.1/web/servicelistreload?mode=2\";', '', '', 2, 'wget -O /etc/enigma2/iptv.sh \{DEVICE_LINK\} && chmod 777 /etc/enigma2/iptv.sh && /etc/enigma2/iptv.sh'),(13, 'm3u With Options', 'm3u_plus', 'tv_channels_\{USERNAME\}_plus.m3u', '#EXTM3U', '#EXTINF:-1 tvg-id=\"\{CHANNEL_ID\}\" tvg-name=\"\{CHANNEL_NAME\}\" tvg-logo=\"\{CHANNEL_ICON\}\" group-title=\"\{CATEGORY\}\",\{CHANNEL_NAME\}\{URL\}', '', 2, NULL),(14, 'StarLive v5', 'starlivev5', 'channel.jason', '', '', '', 2, NULL),(15, 'WebTV List', 'webtvlist', 'webtv list.txt', '', 'Channel name:\{CHANNEL_NAME\}URL:\{URL\}', '[Webtv channel END]', 2, NULL),(16, 'Octagon Auto Script', 'octagon_script', 'iptv', 'USERNAME=\"\{USERNAME\}\";PASSWORD=\"\{PASSWORD\}\";url=\"\{SERVER_URL\}get.php?username=$USERNAME&password=$PASSWORD&type=octagon&output=\{OUTPUT_KEY\}\";rm /var/freetvplus/internettv.feed;wget -O /var/freetvplus/internettv.feed1 $url;chmod 777 /var/freetvplus/internettv.feed1;awk -v BINMODE=3 -v RS=\'(\\r\\n|\\n)\' -v ORS=\'\\n\' \'\{ print \}\' /var/freetvplus/internettv.feed1 > /var/freetvplus/internettv.feed;rm /var/freetvplus/internettv.feed1', '', '', 2, 'wget -qO /var/bin/iptv \{DEVICE_LINK\}'),(18, 'Ariva', 'ariva', 'ariva_\{USERNAME\}.txt', '', '\{CHANNEL_NAME\},\{URL\}', '', 2, NULL),(19, 'Spark', 'spark', 'webtv_usr.xml', '<?xml version=\"1.0\"?><webtvs>', '<webtv title=\"\{CHANNEL_NAME\}\" urlkey=\"0\" url=\"\{URL\}\" description=\"\" iconsrc=\"\{CHANNEL_ICON\}\" iconsrc_b=\"\" group=\"0\" type=\"0\" />', '</webtvs>', 2, NULL),(20, 'Geant/Starsat/Tiger/Qmax/Hyper/Royal', 'gst', '\{USERNAME\}_list.txt', '', 'I: \{URL\} \{CHANNEL_NAME\}', '', 2, NULL),(21, 'Fortec999/Prifix9400/Starport', 'fps', 'Royal.cfg', '', 'IPTV: \{ \{CHANNEL_NAME\} \} \{ \{URL\} \}', '', 2, NULL),(22, 'Revolution 60/60 | Sunplus', 'revosun', 'network_iptv.cfg', '', 'IPTV: \{ \{CHANNEL_NAME\} \} \{ \{URL\} \}', '', 2, NULL), (23, 'Zorro', 'zorro', 'iptv.cfg', '<NETDBS_TXT_VER_1>', 'IPTV: \{ \{CHANNEL_NAME\} \} \{ \{URL\} \} -HIDE_URL', '', 2, NULL);", "CREATE TABLE `streams_arguments` (`id` int(11) NOT NULL, `argument_cat` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `argument_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `argument_description` mediumtext COLLATE utf8_unicode_ci NOT NULL, `argument_wprotocol` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `argument_key` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `argument_cmd` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `argument_type` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `argument_default_value` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;","INSERT INTO `streams_arguments` (`id`, `argument_cat`, `argument_name`, `argument_description`, `argument_wprotocol`, `argument_key`, `argument_cmd`, `argument_type`, `argument_default_value`) VALUES (1, 'fetch', 'User Agent', 'Set a Custom User Agent', 'http', 'user_agent', '-user-agent \"%s\"', 'text', 'Xtream-Codes IPTV Panel Pro'), (2, 'fetch', 'HTTP Proxy', 'Set an HTTP Proxy in this format: ip:port', 'http', 'proxy', '-http_proxy \"%s\"', 'text', NULL), (3, 'transcode', 'Average Video Bit Rate', 'With this you can change the bitrate of the target video. It is very useful in case you want your video to be playable on slow internet connections', NULL, 'bitrate', '-b:v %dk', 'text', NULL), (4, 'transcode', 'Average Audio Bitrate', 'Change Audio Bitrate', NULL, 'audio_bitrate', '-b:a %dk', 'text', NULL), (5, 'transcode', 'Minimum Bitrate Tolerance', '-minrate FFmpeg argument. Specify the minimum bitrate tolerance here. Specify in kbps. Enter INT number.', NULL, 'minimum_bitrate', '-minrate %dk', 'text', NULL), (6, 'transcode', 'Maximum Bitrate Tolerance', '-maxrate FFmpeg argument. Specify the maximum bitrate tolerance here.Specify in kbps. Enter INT number. ', NULL, 'maximum_bitrate', '-maxrate %dk', 'text', NULL), (7, 'transcode', 'Buffer Size', '-bufsize is the rate control buffer. Basically it is assumed that the receiver/end player will buffer that much data so its ok to fluctuate within that much. Specify in kbps. Enter INT number.', NULL, 'bufsize', '-bufsize %dk', 'text', NULL), (8, 'transcode', 'CRF Value', 'The range of the quantizer scale is 0-51: where 0 is lossless, 23 is default, and 51 is worst possible. A lower value is a higher quality and a subjectively sane range is 18-28. Consider 18 to be visually lossless or nearly so: it should look the same or ', NULL, 'crf', '-crf %d', 'text', NULL), (9, 'transcode', 'Scaling', 'Change the Width & Height of the target Video. (Eg. 320:240 ) .  If we\\'d like to keep the aspect ratio, we need to specify only one component, either width or height, and set the other component to -1. (eg 320:-1)', NULL, 'scaling', '-filter_complex \"scale=%s\"', 'text', NULL), (10, 'transcode', 'Aspect', 'Change the target Video Aspect. (eg 16:9)', NULL, 'aspect', '-aspect %s', 'text', NULL), (11, 'transcode', 'Target Video FrameRate', 'Set the frame rate', NULL, 'video_frame_rate', '-r %d', 'text', NULL), (12, 'transcode', 'Audio Sample Rate', 'Set the Audio Sample rate in Hz', NULL, 'audio_sample_rate', '-ar %d', 'text', NULL), (13, 'transcode', 'Audio Channels', 'Specify Audio Channels', NULL, 'audio_channels', '-ac %d', 'text', NULL), (14, 'transcode', 'Remove Sensitive Parts (delogo filter)', 'With this filter you can remove sensitive parts in your video. You will just specifiy the x & y pixels where there is a sensitive area and the width and height that will be removed. Example Use: x=0:y=0:w=100:h=77:band=10 ', NULL, 'delogo', '-filter_complex \"delogo=%s\"', 'text', NULL), (15, 'transcode', 'Threads', 'Specify the number of threads you want to use for the transcoding process. Entering 0 as value will make FFmpeg to choose the most optimal settings', NULL, 'threads', '-threads %d', 'text', NULL), (16, 'transcode', 'Logo Path', 'Add your Own Logo to the stream. The logo will be placed in the upper left. Please be sure that you have selected H.264 as codec otherwise this option won\\'t work. Note that adding your own logo will consume A LOT of cpu power', NULL, 'logo', '-i \"%s\" -filter_complex \"overlay\"', 'text', NULL), (17, 'fetch', 'Cookie', 'Set an HTTP Cookie that might be useful to fetch your INPUT Source.', 'http', 'cookie', '-cookie \\'%s\\'', 'text', NULL), (18, 'transcode', 'DeInterlacing Filter', 'It check pixels of previous, current and next frames to re-create the missed field by some local adaptive method (edge-directed interpolation) and uses spatial check to prevent most artifacts. ', NULL, '', '-filter_complex \"yadif\"', 'radio', '0');", "CREATE TABLE `streams_types` (`type_id` int(11) NOT NULL, `type_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `type_key` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `type_output` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `live` tinyint(4) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;", "INSERT INTO `streams_types` (`type_id`, `type_name`, `type_key`, `type_output`, `live`) VALUES (1, 'Live Streams', 'live', 'live', 1), (2, 'Movies', 'movie', 'movie', 0), (3, 'Created Live Channels', 'created_live', 'live', 1), (4, 'Radio', 'radio_streams', 'live', 1), (5, 'TV Series', 'series', 'series', 0);", "ALTER TABLE `access_output` ADD PRIMARY KEY (`access_output_id`), ADD KEY `output_key` (`output_key`), ADD KEY `output_ext` (`output_ext`);", "ALTER TABLE `cronjobs` ADD PRIMARY KEY (`id`), ADD KEY `enabled` (`enabled`), ADD KEY `filename` (`filename`);", "ALTER TABLE `devices` ADD PRIMARY KEY (`device_id`), ADD KEY `device_key` (`device_key`), ADD KEY `default_output` (`default_output`);", "ALTER TABLE `streams_arguments` ADD PRIMARY KEY (`id`);", "ALTER TABLE `streams_types` ADD PRIMARY KEY (`type_id`), ADD KEY `type_key` (`type_key`), ADD KEY `type_output` (`type_output`), ADD KEY `live` (`live`);", "ALTER TABLE `access_output` MODIFY `access_output_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;", "ALTER TABLE `cronjobs` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;", "ALTER TABLE `devices` MODIFY `device_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=24;", "ALTER TABLE `streams_arguments` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19;", "ALTER TABLE `streams_types` MODIFY `type_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;", "ALTER TABLE `bouquets` ADD COLUMN `bouquet_series` mediumtext COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `epg` ADD COLUMN `days_keep` int(11) NOT NULL DEFAULT '7';", "ALTER TABLE `epg` ADD COLUMN `data` longtext COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `mag_devices` ADD COLUMN `tv_channel_default_aspect` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'fit';", "ALTER TABLE `mag_devices` ADD COLUMN `last_itv_id` int(11) NOT NULL DEFAULT '0';", "ALTER TABLE `mag_devices` ADD COLUMN `units` varchar(20) COLLATE utf8_unicode_ci DEFAULT 'metric';", "ALTER TABLE `mag_devices` ADD COLUMN `token` varchar(32) COLLATE utf8_unicode_ci DEFAULT '';", "ALTER TABLE `mag_devices` ADD COLUMN `lock_device` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `member_groups` ADD COLUMN `delete_users` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `member_groups` ADD COLUMN `allowed_pages` text COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `member_groups` ADD COLUMN `reseller_force_server` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `member_groups` ADD COLUMN `create_sub_resellers_price` float NOT NULL DEFAULT '0';", "ALTER TABLE `member_groups` ADD COLUMN `create_sub_resellers` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `member_groups` ADD COLUMN `alter_packages_ids` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `member_groups` ADD COLUMN `alter_packages_prices` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `member_groups` ADD COLUMN `reseller_client_connection_logs` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `member_groups` ADD COLUMN `reseller_assign_pass` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `member_groups` ADD COLUMN `allow_change_pass` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `member_groups` ADD COLUMN `allow_import` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `member_groups` ADD COLUMN `allow_export` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `member_groups` ADD COLUMN `reseller_trial_credit_allow` int(11) NOT NULL DEFAULT '0';", "ALTER TABLE `member_groups` ADD COLUMN `edit_mac` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `member_groups` ADD COLUMN `edit_isplock` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `member_groups` ADD COLUMN `reset_stb_data` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `member_groups` ADD COLUMN `reseller_bonus_package_inc` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `member_groups` ADD COLUMN `allow_download` tinyint(4) NOT NULL DEFAULT '1';", "ALTER TABLE `packages` ADD COLUMN `is_restreamer` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `packages` ADD COLUMN `force_server_id` int(11) NOT NULL DEFAULT '0';", "ALTER TABLE `packages` ADD COLUMN `can_gen_e2` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `packages` ADD COLUMN `only_e2` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `packages` ADD COLUMN `forced_country` varchar(2) COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `packages` ADD COLUMN `lock_device` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `reg_users` ADD COLUMN `reseller_dns` text COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `reg_users` ADD COLUMN `owner_id` int(11) NOT NULL DEFAULT '0';", "ALTER TABLE `reg_users` ADD COLUMN `override_packages` text COLLATE utf8_unicode_ci;", "ALTER TABLE `reg_users` ADD COLUMN `google_2fa_sec` varchar(50) COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `settings` DROP COLUMN `use_remote_smtp`;", "ALTER TABLE `settings` DROP COLUMN `update_url`;", "ALTER TABLE `settings` DROP COLUMN `test_download_url`;", "ALTER TABLE `settings` DROP COLUMN `show_max_slots_video`;", "ALTER TABLE `settings` DROP COLUMN `max_slots_video_path`;", "ALTER TABLE `settings` ADD COLUMN `reshare_deny_addon` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `settings` ADD COLUMN `restart_http` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `settings` ADD COLUMN `css_layout` varchar(255) COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `settings` ADD COLUMN `flood_seconds` int(11) NOT NULL DEFAULT '5';", "ALTER TABLE `settings` ADD COLUMN `flood_max_attempts` int(11) NOT NULL DEFAULT '1';", "ALTER TABLE `settings` ADD COLUMN `flood_apply_clients` int(11) NOT NULL DEFAULT '1';", "ALTER TABLE `settings` ADD COLUMN `flood_apply_restreamers` int(11) NOT NULL DEFAULT '0';", "ALTER TABLE `settings` ADD COLUMN `backup_source_all` int(11) NOT NULL DEFAULT '0';", "ALTER TABLE `settings` ADD COLUMN `flood_get_block` int(11) NOT NULL DEFAULT '0';", "ALTER TABLE `settings` ADD COLUMN `portal_block` int(11) NOT NULL DEFAULT '0';", "ALTER TABLE `settings` ADD COLUMN `streaming_block` int(11) NOT NULL DEFAULT '0';", "ALTER TABLE `settings` ADD COLUMN `stream_start_delay` int(11) NOT NULL DEFAULT '20000';", "ALTER TABLE `settings` ADD COLUMN `hash_lb` tinyint(4) NOT NULL DEFAULT '1';", "ALTER TABLE `settings` ADD COLUMN `vod_bitrate_plus` int(11) NOT NULL DEFAULT '60';", "ALTER TABLE `settings` ADD COLUMN `read_buffer_size` int(11) NOT NULL DEFAULT '8192';", "ALTER TABLE `settings` ADD COLUMN `tv_channel_default_aspect` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'fit';", "ALTER TABLE `settings` ADD COLUMN `playback_limit` int(11) NOT NULL DEFAULT '3';", "ALTER TABLE `settings` ADD COLUMN `show_tv_channel_logo` tinyint(4) NOT NULL DEFAULT '1';", "ALTER TABLE `settings` ADD COLUMN `show_channel_logo_in_preview` tinyint(4) NOT NULL DEFAULT '1';", "ALTER TABLE `settings` ADD COLUMN `enable_connection_problem_indication` tinyint(4) NOT NULL DEFAULT '1';", "ALTER TABLE `settings` ADD COLUMN `enable_pseudo_hls` tinyint(4) NOT NULL DEFAULT '1';", "ALTER TABLE `settings` ADD COLUMN `vod_limit_at` int(11) NOT NULL DEFAULT '0';", "ALTER TABLE `settings` ADD COLUMN `client_area_plugin` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'flow';", "ALTER TABLE `settings` ADD COLUMN `persistent_connections` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `settings` ADD COLUMN `record_max_length` int(11) NOT NULL DEFAULT '180';", "ALTER TABLE `settings` ADD COLUMN `total_records_length` int(11) NOT NULL DEFAULT '600';", "ALTER TABLE `settings` ADD COLUMN `max_local_recordings` int(11) NOT NULL DEFAULT '10';", "ALTER TABLE `settings` ADD COLUMN `allowed_stb_types_for_local_recording` text COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `settings` ADD COLUMN `allowed_stb_types_rec` text COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `settings` ADD COLUMN `show_captcha` int(11) NOT NULL DEFAULT '1';", "ALTER TABLE `settings` ADD COLUMN `dynamic_timezone` tinyint(4) NOT NULL DEFAULT '1';", "ALTER TABLE `settings` ADD COLUMN `stalker_theme` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'digital';", "ALTER TABLE `settings` ADD COLUMN `rtmp_random` tinyint(4) NOT NULL DEFAULT '1';", "ALTER TABLE `settings` ADD COLUMN `api_ips` text COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `settings` ADD COLUMN `crypt_load_balancing` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '';", "ALTER TABLE `settings` ADD COLUMN `use_buffer` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `settings` ADD COLUMN `restreamer_prebuffer` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `settings` ADD COLUMN `audio_restart_loss` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `settings` ADD COLUMN `stalker_lock_images` mediumtext COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `settings` ADD COLUMN `channel_number_type` varchar(25) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'bouquet';", "ALTER TABLE `settings` ADD COLUMN `stb_change_pass` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `settings` ADD COLUMN `enable_debug_stalker` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `settings` ADD COLUMN `online_capacity_interval` smallint(6) NOT NULL DEFAULT '10';", "ALTER TABLE `settings` ADD COLUMN `always_enabled_subtitles` tinyint(4) NOT NULL DEFAULT '1';", "ALTER TABLE `settings` ADD COLUMN `test_download_url` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '';", "ALTER TABLE `settings` ADD COLUMN `xc_support_allow` tinyint(4) NOT NULL DEFAULT '1';", "ALTER TABLE `settings` ADD COLUMN `e2_arm7a` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '';", "ALTER TABLE `settings` ADD COLUMN `e2_mipsel` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '';", "ALTER TABLE `settings` ADD COLUMN `e2_mips32el` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '';", "ALTER TABLE `settings` ADD COLUMN `e2_sh4` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '';", "ALTER TABLE `settings` ADD COLUMN `e2_arm` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '';", "ALTER TABLE `settings` ADD COLUMN `api_pass` varchar(255) COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `settings` ADD COLUMN `message_of_day` text COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `settings` ADD COLUMN `double_auth` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `settings` ADD COLUMN `mysql_remote_sec` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `settings` ADD COLUMN `enable_isp_lock` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `settings` ADD COLUMN `show_isps` tinyint(4) NOT NULL DEFAULT '1';", "ALTER TABLE `settings` ADD COLUMN `userpanel_mainpage` longtext COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `settings` ADD COLUMN `save_closed_connection` tinyint(4) NOT NULL DEFAULT '1';", "ALTER TABLE `settings` ADD COLUMN `client_logs_save` tinyint(4) NOT NULL DEFAULT '1';", "ALTER TABLE `settings` ADD COLUMN `get_real_ip_client` varchar(255) COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `settings` ADD COLUMN `case_sensitive_line` tinyint(4) NOT NULL DEFAULT '1';", "ALTER TABLE `settings` ADD COLUMN `county_override_1st` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `settings` ADD COLUMN `disallow_2nd_ip_con` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `settings` ADD COLUMN `firewall` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `settings` ADD COLUMN `new_sorting_bouquet` tinyint(4) NOT NULL DEFAULT '1';", "ALTER TABLE `settings` ADD COLUMN `split_by` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'con';", "ALTER TABLE `settings` ADD COLUMN `use_mdomain_in_lists` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `settings` ADD COLUMN `use_https` text COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `settings` ADD COLUMN `priority_backup` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `settings` ADD COLUMN `use_buffer_table` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `settings` ADD COLUMN `tmdb_api_key` text COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `settings` ADD COLUMN `toggle_menu` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `settings` ADD COLUMN `mobile_apps` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `settings` ADD COLUMN `stalker_container_priority` text COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `settings` ADD COLUMN `gen_container_priority` text COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `settings` ADD COLUMN `tmdb_default` varchar(3) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'en';", "ALTER TABLE `settings` ADD COLUMN `series_custom_name` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `settings` ADD COLUMN `mag_security` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `streaming_servers` ADD COLUMN `enable_geoip` int(11) NOT NULL DEFAULT '0';", "ALTER TABLE `streaming_servers` ADD COLUMN `geoip_countries` mediumtext COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `streaming_servers` ADD COLUMN `last_check_ago` int(11) NOT NULL DEFAULT '0';", "ALTER TABLE `streaming_servers` ADD COLUMN `server_hardware` text COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `streaming_servers` ADD COLUMN `total_services` int(11) NOT NULL DEFAULT '3';", "ALTER TABLE `streaming_servers` ADD COLUMN `persistent_connections` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `streaming_servers` ADD COLUMN `rtmp_port` int(11) NOT NULL DEFAULT '8001';", "ALTER TABLE `streaming_servers` ADD COLUMN `geoip_type` varchar(13) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'low_priority';", "ALTER TABLE `streaming_servers` ADD COLUMN `isp_names` mediumtext COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `streaming_servers` ADD COLUMN `isp_type` varchar(13) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'low_priority';", "ALTER TABLE `streaming_servers` ADD COLUMN `enable_isp` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `streaming_servers` ADD COLUMN `boost_fpm` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `streaming_servers` ADD COLUMN `http_ports_add` text COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `streaming_servers` ADD COLUMN `network_guaranteed_speed` int(11) NOT NULL DEFAULT '0';", "ALTER TABLE `streaming_servers` ADD COLUMN `https_broadcast_port` int(11) NOT NULL DEFAULT '25463';", "ALTER TABLE `streaming_servers` ADD COLUMN `https_ports_add` text COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `streaming_servers` ADD COLUMN `whitelist_ips` text COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `streaming_servers` ADD COLUMN `watchdog_data` mediumtext COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `streaming_servers` ADD COLUMN `timeshift_only` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `streams_sys` DROP COLUMN `analyze_start`;", "ALTER TABLE `streams_sys` DROP COLUMN `analyze_pid`;", "ALTER TABLE `streams_sys` DROP COLUMN `crashed_analyze`;", "ALTER TABLE `streams_sys` DROP COLUMN `integrity`;", "ALTER TABLE `streams_sys` ADD COLUMN `monitor_pid` int(11) DEFAULT NULL;", "ALTER TABLE `streams_sys` ADD COLUMN `progress_info` text COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `streams_sys` ADD COLUMN `on_demand` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `streams_sys` ADD COLUMN `delay_pid` int(11) DEFAULT NULL;", "ALTER TABLE `streams_sys` ADD COLUMN `delay_available_at` int(11) DEFAULT NULL;", "ALTER TABLE `stream_categories` ADD COLUMN `parent_id` int(11) NOT NULL DEFAULT '0';", "ALTER TABLE `stream_categories` ADD COLUMN `cat_order` int(11) NOT NULL DEFAULT '0';", "ALTER TABLE `users` ADD COLUMN `is_e2` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `users` ADD COLUMN `bypass_ua` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `users` ADD COLUMN `play_token` text COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `user_activity` DROP COLUMN `last_ts_read`;", "ALTER TABLE `user_activity` DROP COLUMN `last_ts`;", "ALTER TABLE `user_activity_now` DROP COLUMN `last_ts_read`;", "ALTER TABLE `user_activity_now` DROP COLUMN `last_ts`;", "ALTER TABLE `user_activity_now` ADD COLUMN `hls_last_read` int(11) DEFAULT NULL;", "ALTER TABLE `user_activity_now` ADD COLUMN `hls_end` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `streams` DROP COLUMN `target_container_id`;", "ALTER TABLE `streams` DROP COLUMN `auto_restart`;", "ALTER TABLE `streams` DROP COLUMN `create_channel_queue`;", "ALTER TABLE `streams` DROP COLUMN `gen_pts`;", "ALTER TABLE `streams` ADD COLUMN `target_container` text COLLATE utf8_unicode_ci;", "ALTER TABLE `streams` ADD COLUMN `auto_restart` text COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `streams` ADD COLUMN `cchannel_rsources` mediumtext COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `streams` ADD COLUMN `gen_timestamps` tinyint(4) NOT NULL DEFAULT '1';", "ALTER TABLE `streams` ADD COLUMN `series_no` int(11) NOT NULL DEFAULT '0';", "ALTER TABLE `streams` ADD COLUMN `direct_source` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `streams` ADD COLUMN `tv_archive_duration` int(11) NOT NULL DEFAULT '0';", "ALTER TABLE `streams` ADD COLUMN `tv_archive_server_id` int(11) NOT NULL DEFAULT '0';", "ALTER TABLE `streams` ADD COLUMN `tv_archive_pid` int(11) NOT NULL DEFAULT '0';", "ALTER TABLE `streams` ADD COLUMN `movie_symlink` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `streams` ADD COLUMN `redirect_stream` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `streams` ADD COLUMN `rtmp_output` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `streams` ADD COLUMN `number` int(11) NOT NULL;", "ALTER TABLE `streams` ADD COLUMN `allow_record` tinyint(4) NOT NULL DEFAULT '0';", "ALTER TABLE `streams` ADD COLUMN `probesize_ondemand` int(11) NOT NULL DEFAULT '128000';", "ALTER TABLE `streams` ADD COLUMN `custom_map` text COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `streams` ADD COLUMN `external_push` mediumtext COLLATE utf8_unicode_ci NOT NULL;", "ALTER TABLE `streams` ADD COLUMN `delay_minutes` int(11) NOT NULL DEFAULT '0';", "UPDATE `bouquets` SET `bouquet_series` = '[]';", "UPDATE `streaming_servers` SET `ssh_password` = '';"]

def migrate():
    rXCCursor = rXCDB.cursor()
    for rTable in rDelete: rXCCursor.execute("DELETE FROM `%s`;" % rTable)
    for rTable in rDrop: rXCCursor.execute("DROP TABLE IF EXISTS `%s`;" % rTable)
    for rQuery in rQueries:
        try: rXCCursor.execute(rQuery)
        except: pass
    print "Migration completed."
    rXCCursor.commit()
    rXCCursor.close()

if __name__ == "__main__":
    try: rXCDB = MySQLdb.connect(host=rHost, user=rUsername, passwd=rPassword, port=rPort, db=rDatabase)
    except:
        print "Could not connect to database. Please check configuration details."
        sys.exit(1)
    print "Are you sure you want to proceed? Ensure you have backed up your database first!"
    print "This is an experimental converter and is not guaranteed to work."
    if raw_input("PROCEED (Y/N): ").upper() == "Y": migrate()
    rXCDB.close()