Esempio n. 1
0
        static Translation()
        {
            string lang;

            try
            {
                lang = GUILocalizeStrings.GetCultureName(GUILocalizeStrings.CurrentLanguage());
            }
            catch (Exception)
            {
                // when running MovingPicturesConfigTester outside of the MediaPortal directory this happens unfortunately
                // so we grab the active culture name from the system
                lang = CultureInfo.CurrentUICulture.Name;
            }

            BaseConfig.MyAnimeLog.Write("Using language {0}", lang);

            path = Config.GetSubFolder(Config.Dir.Language, "MyAnime3");

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            LoadTranslations(lang);
        }
Esempio n. 2
0
        static Translation()
        {
            string lang;

            try
            {
                lang  = GUILocalizeStrings.GetCultureName(GUILocalizeStrings.CurrentLanguage());
                _info = DateTimeFormatInfo.GetInstance(CultureInfo.CurrentUICulture);
            }
            catch (Exception)
            {
                lang  = CultureInfo.CurrentUICulture.Name;
                _info = DateTimeFormatInfo.GetInstance(CultureInfo.CurrentUICulture);
            }

            Log.Info("Using language " + lang);

            _path = Config.GetSubFolder(Config.Dir.Language, "RadioTime");

            if (!Directory.Exists(_path))
            {
                Directory.CreateDirectory(_path);
            }

            LoadTranslations(lang);
        }
Esempio n. 3
0
        private void LoadTranslations()
        {
            Log.Debug("CecRemote: Loading translated strings for MPEI settings.");

            string lang = "";

            try
            {
                lang = GUILocalizeStrings.GetCultureName(GUILocalizeStrings.CurrentLanguage());
            }
            catch (Exception)
            {
                Log.Debug("CecRemote: Unable to detect current language. Using English.");
                lang = this.DefaultLanguage;
            }

            Log.Debug("CecRemote: MPEI settings language set to " + lang);

            XmlDocument xmlTranslation = new XmlDocument();

            for (short i = 0; i < 2; ++i)
            {
                try
                {
                    string path = Path.Combine(Config.GetSubFolder(Config.Dir.Language, "CecRemote"), lang + ".xml");
                    xmlTranslation.Load(path);
                }
                catch
                {
                    Log.Debug("CecRemote: Could not open translation file for langueage: {0}. Loading default language: {1}", lang, DefaultLanguage);
                    lang = this.DefaultLanguage;
                    continue;
                }
                break;
            }

            foreach (XmlNode node in xmlTranslation.DocumentElement.ChildNodes)
            {
                if (node.NodeType == XmlNodeType.Element)
                {
                    try
                    {
                        GUIPropertyManager.SetProperty("#CecRemote.Translation." + node.Attributes.GetNamedItem("name").Value + ".Label", node.InnerText);
                    }
                    catch (Exception ex)
                    {
                        Log.Error("CecRemote: Error while loading translations. Translation string missing or invalid. " + ex.Message);
                    }
                }
            }
        }
Esempio n. 4
0
        internal static string GetLocalizedText(TextId textId, params object[] args)
        {
            string result = null;

            if ((int)textId > 49000 && (int)textId < 50000)//filter out the mediaportal strings.
            {
                string isoCode = GUILocalizeStrings.GetCultureName(GUILocalizeStrings.CurrentLanguage());
                result = Translator.GetLocalizedText(isoCode, textId);
            }

            if (result == null)
            {
                result = GUILocalizeStrings.Get((int)textId, args);
            }
            return(result == null ? String.Empty : result);
        }
Esempio n. 5
0
        // init the skin
        public override bool Init()
        {
            _setting.Language = GUILocalizeStrings.GetCultureName(GUILocalizeStrings.CurrentLanguage());

            updateStationLogoTimer.AutoReset = true;
            updateStationLogoTimer.Enabled   = false;
            updateStationLogoTimer.Elapsed  += OnDownloadTimedEvent;
            Client.DownloadFileCompleted    += DownloadLogoEnd;

            Settings.NowPlaying        = new RadioTimeNowPlaying();
            Settings.NowPlayingStation = new RadioTimeStation();

            ClearProps();

            // show the skin
            return(Load(GUIGraphicsContext.Skin + @"\radiotime.xml"));
        }
Esempio n. 6
0
        public static string GetLang()
        {
            string lang = string.Empty;

            try
            {
                lang = GUILocalizeStrings.GetCultureName(GUILocalizeStrings.CurrentLanguage());
            }
            catch (Exception)
            {
                lang = CultureInfo.CurrentUICulture.Name;
            }
            if (string.IsNullOrEmpty(lang))
            {
                lang = "EN";
            }
            return(lang);
        }
    public static void Init()
    {
      // reset active translations
      _translations = null;
      FixedTranslations.Clear();

      string lang = string.Empty;
      try
      {
        lang = GUILocalizeStrings.GetCultureName(GUILocalizeStrings.CurrentLanguage());
      }
      catch (Exception)
      {
        lang = CultureInfo.CurrentUICulture.Name;
      }


      if (!System.IO.Directory.Exists(_path))
        System.IO.Directory.CreateDirectory(_path);

      LoadTranslations(lang);
    }
Esempio n. 8
0
        static Translations()
        {
            string lang;

            try {
                lang = GUILocalizeStrings.GetCultureName(GUILocalizeStrings.CurrentLanguage());
            } catch (Exception) {
                // when running MovingPicturesConfigTester outside of the MediaPortal directory this happens unfortunately
                // so we grab the active culture name from the system
                lang = CultureInfo.CurrentUICulture.Name;
            }

            Log.Info("Using language " + lang);

            path = GetPluginLanguagesPath();
            if (!System.IO.Directory.Exists(path))
            {
                System.IO.Directory.CreateDirectory(path);
            }

            LoadTranslations(lang);
        }
Esempio n. 9
0
        static Translator()
        {
            try
            {
                Lang  = GUILocalizeStrings.GetCultureName(GUILocalizeStrings.CurrentLanguage());
                _info = DateTimeFormatInfo.GetInstance(CultureInfo.CurrentUICulture);
            }
            catch (Exception)
            {
                Lang  = CultureInfo.CurrentUICulture.Name;
                _info = DateTimeFormatInfo.GetInstance(CultureInfo.CurrentUICulture);
            }

            Log.Instance.Info("Using language '{0}'", Lang);

            string _path = Config.GetSubFolder(Config.Dir.Language, "OnlineVideos");

            if (!Directory.Exists(_path))
            {
                Directory.CreateDirectory(_path);
            }

            Lang = TranslationLoader.LoadTranslations(Lang, _path);
        }
Esempio n. 10
0
        static Localization()
        {
            try
            {
                Lang  = GUILocalizeStrings.GetCultureName(GUILocalizeStrings.CurrentLanguage());
                _info = DateTimeFormatInfo.GetInstance(CultureInfo.CurrentUICulture);
            }
            catch (Exception)
            {
                Lang  = CultureInfo.CurrentUICulture.Name;
                _info = DateTimeFormatInfo.GetInstance(CultureInfo.CurrentUICulture);
            }

            logger.Info("Using language: " + Lang);

            _path = MediaPortal.Configuration.Config.GetSubFolder(MediaPortal.Configuration.Config.Dir.Language, "mvCentral");

            if (!Directory.Exists(_path))
            {
                Directory.CreateDirectory(_path);
            }

            LoadTranslations();
        }
Esempio n. 11
0
        void Load()
        {
            OnlineVideos.OnlineVideoSettings ovsconf = OnlineVideos.OnlineVideoSettings.Instance;

            ovsconf.UserStore = new UserStore();
            ovsconf.FavDB     = FavoritesDatabase.Instance;
            ovsconf.Logger    = Log.Instance;
            ovsconf.ThumbsDir = Config.GetFolder(Config.Dir.Thumbs) + @"\OnlineVideos\";
            ovsconf.ConfigDir = Config.GetFolder(Config.Dir.Config);
            ovsconf.DllsDir   = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "OnlineVideos\\");

            // When run from MPEI we get an invalid plugin directory, we'll try to rectify that here
            try
            {
                var hasFiles = true;

                if (Directory.Exists(ovsconf.DllsDir))
                {
                    var files = Directory.GetFiles(ovsconf.DllsDir, "OnlineVideos.Sites.*.dll");
                    if (files == null || files.Count() == 0)
                    {
                        hasFiles = false;
                    }
                }
                else
                {
                    hasFiles = false;
                }

                if (!hasFiles)
                {
                    ovsconf.DllsDir = Path.Combine(MediaPortal.Configuration.Config.GetDirectoryInfo(MediaPortal.Configuration.Config.Dir.Plugins).FullName, "Windows\\OnlineVideos");
                }
            }
            catch (Exception ex)
            {
                Log.Instance.Error(ex);
            }

            ovsconf.ThumbsResizeOptions = new OnlineVideos.Downloading.ImageDownloader.ResizeOptions()
            {
                MaxSize       = (int)Thumbs.ThumbLargeResolution,
                Compositing   = Thumbs.Compositing,
                Interpolation = Thumbs.Interpolation,
                Smoothing     = Thumbs.Smoothing
            };
            try
            {
                ovsconf.Locale = CultureInfo.CreateSpecificCulture(GUILocalizeStrings.GetCultureName(GUILocalizeStrings.CurrentLanguage()));
            }
            catch (Exception ex)
            {
                Log.Instance.Error(ex);
            }
            try
            {
                using (Settings settings = new MPSettings())
                {
                    BasicHomeScreenName = settings.GetValueAsString(CFG_SECTION, CFG_BASICHOMESCREEN_NAME, BasicHomeScreenName);
                    siteOrder           = (SiteOrder)settings.GetValueAsInt(CFG_SECTION, CFG_SITEVIEW_ORDER, (int)SiteOrder.AsInFile);
                    currentGroupView    = (GUIFacadeControl.Layout)settings.GetValueAsInt(CFG_SECTION, CFG_GROUPVIEW_MODE, (int)GUIFacadeControl.Layout.List);
                    currentSiteView     = (GUIFacadeControl.Layout)settings.GetValueAsInt(CFG_SECTION, CFG_SITEVIEW_MODE, (int)GUIFacadeControl.Layout.List);
                    currentCategoryView = (GUIFacadeControl.Layout)settings.GetValueAsInt(CFG_SECTION, CFG_CATEGORYVIEW_MODE, (int)GUIFacadeControl.Layout.List);
                    currentVideoView    = (GUIFacadeControl.Layout)settings.GetValueAsInt(CFG_SECTION, CFG_VIDEOVIEW_MODE, (int)GUIFacadeControl.Layout.SmallIcons);

                    ovsconf.ThumbsDir = settings.GetValueAsString(CFG_SECTION, CFG_THUMBNAIL_DIR, ovsconf.ThumbsDir).Replace("/", @"\");
                    if (!ovsconf.ThumbsDir.EndsWith(@"\"))
                    {
                        ovsconf.ThumbsDir = ovsconf.ThumbsDir + @"\";                                    // fix thumbnail dir to include the trailing slash
                    }
                    try { if (!string.IsNullOrEmpty(ovsconf.ThumbsDir) && !Directory.Exists(ovsconf.ThumbsDir))
                          {
                              Directory.CreateDirectory(ovsconf.ThumbsDir);
                          }
                    }
                    catch (Exception e) { Log.Instance.Error("Failed to create thumb dir: {0}", e.ToString()); }
                    ThumbsAge = settings.GetValueAsInt(CFG_SECTION, CFG_THUMBNAIL_AGE, ThumbsAge);
                    Log.Instance.Info("Thumbnails will be stored in {0} with a maximum age of {1} days.", ovsconf.ThumbsDir, ThumbsAge);

                    ovsconf.DownloadDir = settings.GetValueAsString(CFG_SECTION, CFG_DOWNLOAD_DIR, "");
                    try { if (!string.IsNullOrEmpty(ovsconf.DownloadDir) && !Directory.Exists(ovsconf.DownloadDir))
                          {
                              Directory.CreateDirectory(ovsconf.DownloadDir);
                          }
                    }
                    catch (Exception e) { Log.Instance.Error("Failed to create download dir: {0}", e.ToString()); }

                    ovsconf.CacheTimeout           = settings.GetValueAsInt(CFG_SECTION, CFG_CACHE_TIMEOUT, ovsconf.CacheTimeout);
                    ovsconf.UseAgeConfirmation     = settings.GetValueAsBool(CFG_SECTION, CFG_USE_AGECONFIRMATION, ovsconf.UseAgeConfirmation);
                    ovsconf.UtilTimeout            = settings.GetValueAsInt(CFG_SECTION, CFG_UTIL_TIMEOUT, ovsconf.UtilTimeout);
                    ovsconf.DynamicCategoryTimeout = settings.GetValueAsInt(CFG_SECTION, CFG_CATEGORYDISCOVERED_TIMEOUT, ovsconf.DynamicCategoryTimeout);

                    // set an almost random string by default -> user must enter pin in Configuration before beeing able to watch adult sites
                    pinAgeConfirmation = settings.GetValueAsString(CFG_SECTION, CFG_PIN_AGECONFIRMATION, DateTime.Now.Millisecond.ToString());
                    useQuickSelect     = settings.GetValueAsBool(CFG_SECTION, CFG_USE_QUICKSELECT, useQuickSelect);
                    wmpbuffer          = settings.GetValueAsInt(CFG_SECTION, CFG_WMP_BUFFER, wmpbuffer);
                    playbuffer         = settings.GetValueAsInt(CFG_SECTION, CFG_PLAY_BUFFER, playbuffer);
                    email    = settings.GetValueAsString(CFG_SECTION, CFG_EMAIL, "");
                    password = settings.GetValueAsString(CFG_SECTION, CFG_PASSWORD, "");
                    string lsFilter = settings.GetValueAsString(CFG_SECTION, CFG_FILTER, "").Trim();
                    FilterArray       = lsFilter != "" ? lsFilter.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries) : null;
                    searchHistoryNum  = settings.GetValueAsInt(CFG_SECTION, CFG_SEARCHHISTORY_NUM, searchHistoryNum);
                    searchHistoryType = (SearchHistoryType)settings.GetValueAsInt(CFG_SECTION, CFG_SEARCHHISTORYTYPE, (int)searchHistoryType);

                    string searchHistoryXML = settings.GetValueAsString(CFG_SECTION, CFG_SEARCHHISTORY, "").Trim();
                    if ("" != searchHistoryXML)
                    {
                        try
                        {
                            byte[]       searchHistoryBytes = System.Text.Encoding.UTF8.GetBytes(searchHistoryXML);
                            MemoryStream xmlMem             = new MemoryStream(searchHistoryBytes);
                            xmlMem.Position = 0;
                            System.Runtime.Serialization.DataContractSerializer dcs = new System.Runtime.Serialization.DataContractSerializer(typeof(Dictionary <string, List <string> >));
                            searchHistory = (Dictionary <string, List <string> >)dcs.ReadObject(xmlMem);
                        }
                        catch (Exception e)
                        {
                            Log.Instance.Warn("Error reading search history from configuration: {0}:{1}! Clearing...", e.GetType(), e.Message);
                            searchHistory = null;
                        }
                    }
                    if (null == searchHistory)
                    {
                        searchHistory = new Dictionary <string, List <string> >();
                    }

                    // set updateOnStart only when defined, so we have 3 modes: undefined = ask, true = don't ask and update, false = don't ask and don't update
                    string doUpdateString = settings.GetValue(CFG_SECTION, CFG_UPDATEONSTART);
                    if (!string.IsNullOrEmpty(doUpdateString))
                    {
                        updateOnStart = settings.GetValueAsBool(CFG_SECTION, CFG_UPDATEONSTART, true);
                    }

                    // last point in time the plugin was run in mediaportal
                    string tempDate = settings.GetValueAsString(CFG_SECTION, CFG_LAST_FIRSTRUN, string.Empty);
                    if (!string.IsNullOrEmpty(tempDate))
                    {
                        DateTime.TryParse(tempDate, out lastFirstRun);
                    }

                    updatePeriod = (uint)settings.GetValueAsInt(CFG_SECTION, CFG_UPDATEPERIOD, (int)updatePeriod);

                    // read the video extensions configured in MediaPortal
                    string[] mediaportal_user_configured_video_extensions;
                    string   strTmp = settings.GetValueAsString("movies", "extensions", ".avi,.mpg,.ogm,.mpeg,.mkv,.wmv,.ifo,.qt,.rm,.mov,.sbe,.dvr-ms,.ts");
                    mediaportal_user_configured_video_extensions = strTmp.Split(',');
                    var listOfExtensions = mediaportal_user_configured_video_extensions.ToList();
                    listOfExtensions.AddRange(new string[] { ".asf", ".asx", ".flv", ".m4v", ".mov", ".mp4", ".wmv" });
                    listOfExtensions = listOfExtensions.Distinct().ToList();
                    listOfExtensions.Sort();
                    ovsconf.AddSupportedVideoExtensions(listOfExtensions);

                    autoGroupByLang        = settings.GetValueAsBool(CFG_SECTION, CFG_AUTO_LANG_GROUPS, autoGroupByLang);
                    ovsconf.FavoritesFirst = settings.GetValueAsBool(CFG_SECTION, CFG_FAVORITES_FIRST, ovsconf.FavoritesFirst);

                    LatestVideosRandomize         = settings.GetValueAsBool(CFG_SECTION, CFG_LATESTVIDEOS_RANDOMIZE, LatestVideosRandomize);
                    LatestVideosMaxItems          = (uint)settings.GetValueAsInt(CFG_SECTION, CFG_LATESTVIDEOS_MAXITEMS, (int)LatestVideosMaxItems);
                    LatestVideosOnlineDataRefresh = (uint)settings.GetValueAsInt(CFG_SECTION, CFG_LATESTVIDEOS_ONLINEDATA_REFRESH, (int)LatestVideosOnlineDataRefresh);
                    LatestVideosGuiDataRefresh    = (uint)settings.GetValueAsInt(CFG_SECTION, CFG_LATESTVIDEOS_GUIDATA_REFRESH, (int)LatestVideosGuiDataRefresh);

                    AllowRefreshRateChange = settings.GetValueAsBool(CFG_SECTION, CFG_ALLOW_REFRESHRATE_CHANGE, AllowRefreshRateChange);
                    StoreLayoutPerCategory = settings.GetValueAsBool(CFG_SECTION, CFG_STORE_LAYOUT_PER_CATEGORY, StoreLayoutPerCategory);

                    ovsconf.HttpPreferredNetworkInterface    = settings.GetValueAsString(CFG_SECTION, CFG_FILTER_V2_HTTP_PREFERRED_NETWORK_INTERFACE, OnlineVideoSettings.NetworkInterfaceSystemDefault);
                    ovsconf.HttpOpenConnectionTimeout        = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_HTTP_OPEN_CONNECTION_TIMEOUT, ovsconf.HttpOpenConnectionTimeout);
                    ovsconf.HttpOpenConnectionSleepTime      = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_HTTP_OPEN_CONNECTION_SLEEP_TIME, ovsconf.HttpOpenConnectionSleepTime);
                    ovsconf.HttpTotalReopenConnectionTimeout = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_HTTP_TOTAL_REOPEN_CONNECTION_TIMEOUT, ovsconf.HttpTotalReopenConnectionTimeout);

                    ovsconf.RtmpPreferredNetworkInterface    = settings.GetValueAsString(CFG_SECTION, CFG_FILTER_V2_RTMP_PREFERRED_NETWORK_INTERFACE, OnlineVideoSettings.NetworkInterfaceSystemDefault);
                    ovsconf.RtmpOpenConnectionTimeout        = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_RTMP_OPEN_CONNECTION_TIMEOUT, ovsconf.RtmpOpenConnectionTimeout);
                    ovsconf.RtmpOpenConnectionSleepTime      = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_RTMP_OPEN_CONNECTION_SLEEP_TIME, ovsconf.RtmpOpenConnectionSleepTime);
                    ovsconf.RtmpTotalReopenConnectionTimeout = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_RTMP_TOTAL_REOPEN_CONNECTION_TIMEOUT, ovsconf.RtmpTotalReopenConnectionTimeout);

                    ovsconf.RtspPreferredNetworkInterface    = settings.GetValueAsString(CFG_SECTION, CFG_FILTER_V2_RTSP_PREFERRED_NETWORK_INTERFACE, OnlineVideoSettings.NetworkInterfaceSystemDefault);
                    ovsconf.RtspOpenConnectionTimeout        = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_RTSP_OPEN_CONNECTION_TIMEOUT, ovsconf.RtspOpenConnectionTimeout);
                    ovsconf.RtspOpenConnectionSleepTime      = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_RTSP_OPEN_CONNECTION_SLEEP_TIME, ovsconf.RtspOpenConnectionSleepTime);
                    ovsconf.RtspTotalReopenConnectionTimeout = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_RTSP_TOTAL_REOPEN_CONNECTION_TIMEOUT, ovsconf.RtspTotalReopenConnectionTimeout);

                    ovsconf.RtspClientPortMin = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_RTSP_CLIENT_PORT_MIN, ovsconf.RtspClientPortMin);
                    ovsconf.RtspClientPortMax = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_RTSP_CLIENT_PORT_MAX, ovsconf.RtspClientPortMax);

                    ovsconf.UdpRtpPreferredNetworkInterface    = settings.GetValueAsString(CFG_SECTION, CFG_FILTER_V2_UDPRTP_PREFERRED_NETWORK_INTERFACE, OnlineVideoSettings.NetworkInterfaceSystemDefault);
                    ovsconf.UdpRtpOpenConnectionTimeout        = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_UDPRTP_OPEN_CONNECTION_TIMEOUT, ovsconf.UdpRtpOpenConnectionTimeout);
                    ovsconf.UdpRtpOpenConnectionSleepTime      = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_UDPRTP_OPEN_CONNECTION_SLEEP_TIME, ovsconf.UdpRtpOpenConnectionSleepTime);
                    ovsconf.UdpRtpTotalReopenConnectionTimeout = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_UDPRTP_TOTAL_REOPEN_CONNECTION_TIMEOUT, ovsconf.UdpRtpTotalReopenConnectionTimeout);
                    ovsconf.UdpRtpReceiveDataCheckInterval     = settings.GetValueAsInt(CFG_SECTION, CFG_FILTER_V2_UDPRTP_RECEIVE_DATA_CHECK_INTERVAL, ovsconf.UdpRtpReceiveDataCheckInterval);
                }
                LoadSitesGroups();
                ovsconf.LoadSites();
            }
            catch (Exception e)
            {
                Log.Instance.Error(e);
            }
        }
Esempio n. 12
0
        public static void LoadTranslations()
        {
            string _path = Config.GetSubFolder(Config.Dir.Language, "Exif");

            if (!System.IO.Directory.Exists(_path))
            {
                return;
            }

            string lang = string.Empty;

            try
            {
                lang = GUILocalizeStrings.GetCultureName(GUILocalizeStrings.CurrentLanguage());
            }
            catch (Exception ex)
            {
                Log.Debug("Loadtranslations: {0}", ex.Message);
                lang = CultureInfo.CurrentUICulture.Name;
            }
            if (lang == "en")
            {
                return;
            }

            string langPath = Path.Combine(_path, lang + ".xml");

            if (!File.Exists(langPath))
            {
                return;
            }

            XmlDocument doc = new XmlDocument();

            try
            {
                Log.Debug(string.Format("EXIF Translation: Try load Translation file {0}.", langPath));
                doc.Load(langPath);
                Log.Info(string.Format("EXIF Translation: Translation file loaded {0}.", langPath));
            }
            catch (Exception e)
            {
                Log.Info(string.Format("EXIF Translation: Error in translation xml file: {0}. Failing back to English", lang));
                Log.Debug("EXIF Translation:" + e.ToString());
                return;
            }

            foreach (XmlNode stringEntry in doc.DocumentElement.ChildNodes)
            {
                if (stringEntry.NodeType == XmlNodeType.Element)
                {
                    try
                    {
                        _translated.Add(stringEntry.Attributes.GetNamedItem("name").Value, stringEntry.InnerText);
                    }
                    catch (Exception ex)
                    {
                        Log.Error("EXIF Translation:" + ex.ToString());
                    }
                }
            }
        }
Esempio n. 13
0
        private string GetAddressURL(double lat, double lon)
        {
            string addrurl = GUILocalizeStrings.Get(9091);

            if (!Util.Utils.IsURL(addrurl))
            {
                return(string.Empty);
            }

            try
            {
                addrurl = String.Format(addrurl, lat.ToMapString(), lon.ToMapString(), GUILocalizeStrings.GetCultureName(GUILocalizeStrings.CurrentLanguage()));
                return(addrurl);
            }
            catch
            {
                Log.Debug("GetAddressURL: Wrong Address URL {0}", GUILocalizeStrings.Get(9090));
            }
            return(string.Empty);
        }
Esempio n. 14
0
 public static string GetCurrentCultureLanguage()
 {
     return(GUILocalizeStrings.GetCultureName(GUILocalizeStrings.CurrentLanguage()));
 }
Esempio n. 15
0
        public bool SetSkinProperties(YouTubeEntry youTubeEntry, string prefix, bool grab, bool download)
        {
            if (youTubeEntry == null)
            {
                return(true);
            }
            ArtistItem artistItem = DatabaseProvider.InstanInstance.GetArtist(youTubeEntry);

            if (artistItem == null && grab)
            {
                string vidId = Youtube2MP.GetVideoId(youTubeEntry);
                artistItem = SitesCache.GetByVideoId(vidId) != null
                       ? Grabber.GetFromVideoSite(SitesCache.GetByVideoId(vidId).SIte)
                       : Grabber.GetFromVideoId(vidId);
            }
            if (artistItem == null)
            {
                string art = GetArtistName(youTubeEntry.Title.Text);
                artistItem = GetArtistsByName(art);
            }
            if ((artistItem == null || string.IsNullOrEmpty(artistItem.Bio) || string.IsNullOrEmpty(artistItem.Img_url)) && grab)
            {
                if (artistItem == null || string.IsNullOrEmpty((artistItem.Name)))
                {
                    artistItem = new ArtistItem()
                    {
                        Name = GetArtistName(youTubeEntry.Title.Text)
                    }
                }
                ;

                try
                {
                    Lastfm.Services.Artist artist = new Lastfm.Services.Artist(artistItem.Name, Youtube2MP.LastFmProfile.Session);
                    if (string.IsNullOrEmpty(artistItem.Img_url))
                    {
                        artistItem.Img_url = artist.GetImageURL(ImageSize.Huge);
                    }
                    if (string.IsNullOrEmpty(artistItem.Bio))
                    {
                        ArtistBio artistBio = artist.Bio;
                        artistBio.Lang = GUILocalizeStrings.GetCultureName(GUILocalizeStrings.CurrentLanguage());
                        string contents = Regex.Replace(HttpUtility.HtmlDecode(artistBio.getContent()), "<.*?>",
                                                        string.Empty);
                        if (string.IsNullOrEmpty(contents))
                        {
                            artistBio.Lang = string.Empty;
                            contents       = Regex.Replace(HttpUtility.HtmlDecode(artistBio.getContent()), "<.*?>",
                                                           string.Empty);
                        }
                        artistItem.Bio = contents;
                    }
                    if (string.IsNullOrEmpty(artistItem.Tags))
                    {
                        int      i       = 0;
                        string   tags    = "";
                        TopTag[] topTags = artist.GetTopTags();
                        foreach (TopTag tag in topTags)
                        {
                            tags += tag.Item.Name + "|";
                            if (i < 5)
                            {
                                if (!string.IsNullOrEmpty(artistItem.Id))
                                {
                                    SaveTag(artistItem, tag.Item.Name);
                                }
                            }
                            i++;
                        }
                        artistItem.Tags = tags;
                    }
                    DatabaseProvider.InstanInstance.AddArtist(artistItem);
                }
                catch (Exception exception)
                {
                    Log.Debug(exception.Message);
                }
            }
            if (artistItem != null)
            {
                if (download && !File.Exists(artistItem.LocalImage))
                {
                    Youtube2MP.DownloadFile(artistItem.Img_url, artistItem.LocalImage);
                }
                SetSkinProperties(artistItem, prefix);
            }
            return(false);
        }