2019-02-04 16:39:48 +00:00
|
|
|
#ifndef TV_FUNCTIONS_H
|
|
|
|
#define TV_FUNCTIONS_H
|
2018-09-22 22:50:42 +00:00
|
|
|
|
2019-01-17 16:08:51 +00:00
|
|
|
#include <map>
|
2019-02-04 16:39:48 +00:00
|
|
|
#include <set>
|
|
|
|
#include <string>
|
2019-07-12 21:10:40 +00:00
|
|
|
#include <unordered_map>
|
2020-01-17 13:11:03 +00:00
|
|
|
#include <unordered_set>
|
2019-01-23 19:46:03 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2019-02-04 16:39:48 +00:00
|
|
|
#include "network.hpp"
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
|
|
|
using string = std::wstring;
|
|
|
|
using char_t = wchar_t;
|
|
|
|
|
2019-04-01 18:18:47 +00:00
|
|
|
std::wstring utf8_to_wstring( const std::string &utf8 );
|
2020-04-01 11:42:00 +00:00
|
|
|
std::wstring LMsg( int id, ... );
|
2020-03-12 19:52:23 +00:00
|
|
|
|
2020-04-01 11:42:00 +00:00
|
|
|
#define _( x, ... ) LMsg( x, ##__VA_ARGS__ ).c_str()
|
2019-04-01 18:18:47 +00:00
|
|
|
|
2019-02-04 16:39:48 +00:00
|
|
|
#else
|
|
|
|
|
2020-03-12 19:52:23 +00:00
|
|
|
#include <libintl.h>
|
|
|
|
|
2019-02-04 16:39:48 +00:00
|
|
|
using string = std::string;
|
|
|
|
using char_t = char;
|
|
|
|
|
2020-03-12 19:52:23 +00:00
|
|
|
std::string getlocalized( const char *id, ... );
|
|
|
|
|
|
|
|
#define TEXT( x ) x
|
|
|
|
#define _( x, ... ) getlocalized( x, ##__VA_ARGS__ )
|
2020-01-15 23:00:58 +00:00
|
|
|
|
2019-02-04 16:39:48 +00:00
|
|
|
#endif
|
|
|
|
|
2019-07-12 21:10:40 +00:00
|
|
|
#ifndef GUI
|
|
|
|
// CLI functions
|
2018-09-22 22:50:42 +00:00
|
|
|
void printHelp();
|
2020-03-12 19:52:23 +00:00
|
|
|
void printPatternHelp();
|
2018-09-22 22:50:42 +00:00
|
|
|
|
2019-02-04 16:39:48 +00:00
|
|
|
bool searchSeason( const char_t *const path, size_t &season_pos );
|
2020-01-17 13:11:03 +00:00
|
|
|
bool searchSeason( const char_t *const path, size_t &season_pos,
|
|
|
|
size_t &ep_pos );
|
2019-01-07 21:23:15 +00:00
|
|
|
|
2019-02-04 16:39:48 +00:00
|
|
|
void parseSeasonNumbers( std::set< int > &seasons_num, const char_t *argument );
|
2019-01-19 12:40:10 +00:00
|
|
|
|
2019-04-01 18:18:47 +00:00
|
|
|
#endif // GUI
|
2019-01-23 19:46:03 +00:00
|
|
|
|
2020-01-16 10:12:22 +00:00
|
|
|
string encodeUrl( const string &url );
|
2019-06-04 19:54:00 +00:00
|
|
|
string userHome();
|
|
|
|
|
2020-01-15 22:59:39 +00:00
|
|
|
void prepareDB( const string &_pattern = TEXT( "" ) );
|
2019-06-04 19:54:00 +00:00
|
|
|
#ifndef GUI
|
2020-01-18 21:18:58 +00:00
|
|
|
void addToDB( string &show, const string &path, const string &language,
|
2020-01-15 21:23:11 +00:00
|
|
|
bool linux, bool dvd );
|
2019-07-12 21:10:40 +00:00
|
|
|
#else
|
2020-01-17 19:54:26 +00:00
|
|
|
void addToDB( const string &show, const string &path, const string &language,
|
2020-01-17 13:11:03 +00:00
|
|
|
const string &id, const string &pattern, bool linux, bool dvd,
|
|
|
|
void *progress_ptr );
|
2019-07-12 21:10:40 +00:00
|
|
|
#endif
|
2019-06-04 19:54:00 +00:00
|
|
|
void removeFromDB( const string &path );
|
|
|
|
void changeDBPattern( const string &pattern );
|
2020-01-17 13:11:03 +00:00
|
|
|
#ifndef GUI
|
2020-01-15 09:00:25 +00:00
|
|
|
void refreshDB( bool linux );
|
2020-01-17 13:11:03 +00:00
|
|
|
#else
|
|
|
|
void refreshDB( bool linux, void *progress_ptr );
|
|
|
|
#endif
|
|
|
|
#ifndef GUI
|
2020-01-15 09:00:25 +00:00
|
|
|
void updateDB( bool linux );
|
2020-01-17 13:11:03 +00:00
|
|
|
#else
|
|
|
|
void updateDB( bool linux, void *progress_ptr );
|
|
|
|
#endif
|
2019-06-04 19:54:00 +00:00
|
|
|
void cleanDB();
|
2020-01-18 21:18:58 +00:00
|
|
|
|
|
|
|
#ifdef GUI
|
2020-02-25 09:08:34 +00:00
|
|
|
std::vector< std::unordered_map< string, string > > dbGetShows();
|
2019-07-12 21:10:40 +00:00
|
|
|
void changeDB( size_t index, const string &path, const string &language,
|
2020-01-17 13:11:03 +00:00
|
|
|
const string &id, bool dvd );
|
2020-01-17 19:54:26 +00:00
|
|
|
void refreshSelectDB( std::unordered_set< size_t > indexes, bool linux,
|
2020-01-17 13:11:03 +00:00
|
|
|
void *progress_ptr );
|
2020-02-25 09:08:34 +00:00
|
|
|
void renameFiles( const std::vector< std::tuple< int, string, string, string > >
|
|
|
|
&renamed_files );
|
2020-01-17 13:11:03 +00:00
|
|
|
#endif
|
2019-06-04 19:54:00 +00:00
|
|
|
|
2020-01-15 18:55:24 +00:00
|
|
|
void iterateFS( std::map< int, std::map< int, string > > &seasons,
|
2019-02-04 16:39:48 +00:00
|
|
|
const string &path );
|
2019-01-23 19:46:03 +00:00
|
|
|
|
2019-02-04 16:39:48 +00:00
|
|
|
string compilePattern( const string &pattern, int season, int episode,
|
|
|
|
const string &filename, const string &episodeName,
|
|
|
|
const string &showName );
|
2020-01-17 13:11:03 +00:00
|
|
|
string getDBPattern();
|
2019-01-21 19:30:14 +00:00
|
|
|
|
2018-09-22 22:50:42 +00:00
|
|
|
#endif
|